Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android显式问题_Android_Manifest_Android Manifest - Fatal编程技术网

Android显式问题

Android显式问题,android,manifest,android-manifest,Android,Manifest,Android Manifest,每当我运行程序时,都会出现以下错误: 10-11 17:53:12.135: ERROR/AndroidRuntime(403): at android.app.Instrumentation.newApplication(Instrumentation.java:957) 10-11 17:53:12.135: ERROR/AndroidRuntime(403): at android.app.Instrumentation.newApplication(Instrumenta

每当我运行程序时,都会出现以下错误:

10-11 17:53:12.135: ERROR/AndroidRuntime(403):     at android.app.Instrumentation.newApplication(Instrumentation.java:957)
10-11 17:53:12.135: ERROR/AndroidRuntime(403):     at android.app.Instrumentation.newApplication(Instrumentation.java:942)
10-11 17:53:12.135: ERROR/AndroidRuntime(403):     at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
10-11 17:53:12.135: ERROR/AndroidRuntime(403):     ... 11 more
10-11 17:53:53.525: ERROR/AndroidRuntime(434): FATAL EXCEPTION: main
10-11 17:53:53.525: ERROR/AndroidRuntime(434): java.lang.RuntimeException: Unable to instantiate application eggplant.passerator.Passerator: java.lang.ClassCastException: eggplant.passerator.Passerator
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread.access$3000(ActivityThread.java:125)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.os.Looper.loop(Looper.java:123)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at java.lang.reflect.Method.invokeNative(Native Method)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at java.lang.reflect.Method.invoke(Method.java:521)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at dalvik.system.NativeStart.main(Native Method)
10-11 17:53:53.525: ERROR/AndroidRuntime(434): Caused by: java.lang.ClassCastException: eggplant.passerator.Passerator
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.Instrumentation.newApplication(Instrumentation.java:957)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.Instrumentation.newApplication(Instrumentation.java:942)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
10-11 17:53:53.525: ERROR/AndroidRuntime(434):     ... 11 more
。我不知道为什么!!!!这以前没有发生过

!<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
              package="eggplant.passerator"
              android:versionCode="1"
              android:versionName="1.0">
            <application android:icon="@drawable/icon" android:label="@string/app_name" android:name="Passerator">
                <activity android:name=".Passerator" android:label="@string/app_name">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>

            </application>



        </manifest>







    package eggplant.passerator;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import java.util.Random;

public class Passerator extends Activity {
    /** Called when the activity is first created. */
    private String[] all_letters = {"a", "b", "c", "d", "e", "f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    private String[] all_words = {"app","apple", "android", "beta","brown", "cow","camp", "down","dug", "elephant","eclair", "fail","full", "gone","got","how","honey","ill","ice","jog","journey","king","kangaroo", "lemon","lobster","mark","make","nose","none", "origin","octpus", "power","pick", "quadrant","respect","run","sun","seen","tons","tan", "under","unable","view","venus", "what","where","yes","yawn","zebra"};
    @SuppressWarnings("unused")
    private Button generateButton;
    private EditText minimum;
    private EditText maximum;
    private CheckBox letters;
    private CheckBox words;
    private CheckBox numbers;
    private EditText password;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.generateButton = (Button)this.findViewById(R.id.generate);
        this.minimum = (EditText)this.findViewById(R.id.min);
        this.maximum = (EditText)this.findViewById(R.id.max);
        this.letters = (CheckBox)this.findViewById(R.id.letters);
        this.words = (CheckBox)this.findViewById(R.id.words);
        this.numbers = (CheckBox)this.findViewById(R.id.numbers);
        this.password = (EditText)this.findViewById(R.id.password);
    }
    public void generate(View v)
    {
        String mi = minimum.getText().toString();
        String ma = maximum.getText().toString();
        Boolean num = numbers.isChecked();
        Boolean let = letters.isChecked();
        Boolean word = words.isChecked();
        String new_password = make_password(mi, ma, num, let, word);
        password.setText(new_password);
    }
    @SuppressWarnings("finally")
    public String make_password(String max, String min, Boolean numbers, Boolean letters, Boolean words)
    {
        String password = new String("");
        int minimum=0;
        int maximum=0;
        try
        {
            minimum = Integer.parseInt(min);
            maximum = Integer.parseInt(max);
        }
        catch(Throwable t)
        {
            password = "You must set both the minimum and maximum to an integer!";
        }
        finally
        {
            //if(numbers==true)password+="numbers,";
            //if(letters==true)password+="letters,";
            //if(words==true)password+="words.";

            Random random_gen = new Random();
            int length = minimum + (int) (Math.random()*(maximum - minimum));
            //password+=Integer.toString(length);
            //password+=":";

            if(numbers==false&&letters==true&&words==false)
            {
                while(length!=0)
                {
                    password+=all_letters[random_gen.nextInt(26)];
                    length-=1;
                }
            }
            if(numbers==false&&letters==false&&words==true)
            {
                if (length<3)password="To use words only, you must set minimum to at least 3!";
                while(length>3)
                {
                    String chosen_word=all_words[random_gen.nextInt(all_words.length)];
                    if (chosen_word.length()<=length)
                    {
                    password+=chosen_word;
                    length-=chosen_word.length();
                    }
                }
            }
            if(numbers==true&&letters==false&&words==false)
            {
                while(length!=0)
                {
                    password+=Integer.toString(random_gen.nextInt(9));
                    length-=1;
                }
            }
            if(numbers==true&&letters==true&&words==false)
            {
                while(length!=0)
                {
                    if(random_gen.nextBoolean()==true)password+=all_letters[random_gen.nextInt(26)];
                    else password+=Integer.toString(random_gen.nextInt(9));
                    length-=1;
                }
            }
            if(numbers==true&&letters==false&&words==true)
            {
                while(length!=0)
                {
                    if(random_gen.nextBoolean()==true)
                    {
                        password+=Integer.toString(random_gen.nextInt(9));
                        length-=1;
                    }
                    else
                    {
                        if(length>3)
                        {
                            String chosen_word=all_words[random_gen.nextInt(all_words.length)];
                            if (chosen_word.length()<=length)
                            {
                                password+=chosen_word;
                                length-=chosen_word.length();
                            }
                        }
                    }
                }
            }
            if(numbers==false&&letters==true&&words==true)
            {
                while(length!=0)
                {
                    if(random_gen.nextBoolean()==true)
                    {
                        password+=all_letters[random_gen.nextInt(26)];
                        length-=1;
                    }
                    else
                    {
                        if(length>3)
                        {
                            String chosen_word=all_words[random_gen.nextInt(all_words.length)];
                            if (chosen_word.length()<=length)
                            {
                                password+=chosen_word;
                                length-=chosen_word.length();
                            }
                        }
                    }   
                }
            }
            if(numbers==true&&letters==true&&words==true)
            {
                while(length!=0)
                {
                    int choice=random_gen.nextInt(3);
                    if(choice==0)
                    {
                        password+=all_letters[random_gen.nextInt(26)];
                        length-=1;
                    }
                    if (choice==1)
                    {
                        if(length>3)
                        {
                            String chosen_word=all_words[random_gen.nextInt(all_words.length)];
                            if (chosen_word.length()<=length)
                            {
                                password+=chosen_word;
                                length-=chosen_word.length();
                            }
                        }
                    }
                    if (choice==2)
                    {
                        password+=Integer.toString(random_gen.nextInt(9));
                        length-=1;
                    }

                }
            }
            if(numbers==false&&letters==false&&words==false)password="You must check at least one of the check boxes above!";
            if (minimum<maximum)password="The maximum must be less than the minimum!";
            return password;
        }
    }
}



<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget35"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="@+id/generate"
android:layout_width="320px"
android:layout_height="53px"
android:text="Generate"
android:layout_x="0px"
android:layout_y="272px"

>
</Button>
<EditText
android:id="@+id/password"
android:layout_width="320px"
android:layout_height="110px"
android:textSize="18sp"
android:layout_x="0px"
android:layout_y="322px"
>
</EditText>
<CheckBox
android:id="@+id/numbers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Numbers"
android:layout_x="200px"
android:layout_y="202px"
>
</CheckBox>
<CheckBox
android:id="@+id/words"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Words"
android:layout_x="110px"
android:layout_y="202px"
>
</CheckBox>
<CheckBox
android:id="@+id/letters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Letters"
android:layout_x="20px"
android:layout_y="202px"
>
</CheckBox>
<EditText
android:id="@+id/max"
android:layout_width="70px"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_x="10px"
android:layout_y="122px"
android:inputType="number"
android:maxLines="1"
android:maxLength="2"
android:imeOptions="actionDone"
>
</EditText>
<EditText
android:id="@+id/min"
android:layout_width="70px"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_x="10px"
android:layout_y="72px"
android:inputType="number"
android:maxLines="1"
android:maxLength="2"
android:imeOptions="actionDone"
>
</EditText>
<TextView
android:id="@+id/max_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Maximum Length"
android:layout_x="80px"
android:layout_y="132px"
>
</TextView>
<TextView
android:id="@+id/min_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Minimum Length"
android:layout_x="80px"
android:layout_y="82px"
>
</TextView>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Passerator"
android:textSize="40sp"
android:textStyle="bold"
android:layout_x="50px"
android:layout_y="2px"
>
</TextView>
</AbsoluteLayout>
!
包装茄子;
导入android.app.Activity;
导入android.os.Bundle;
导入android.view.view;
导入android.widget.Button;
导入android.widget.CheckBox;
导入android.widget.EditText;
导入java.util.Random;
公共类过路人扩展活动{
/**在首次创建活动时调用*/
私有字符串[]所有_字母={“a”、“b”、“c”、“d”、“e”、“f”、“g”、“h”、“i”、“j”、“k”、“l”、“m”、“n”、“o”、“p”、“q”、“r”、“s”、“t”、“u”、“v”、“w”、“x”、“y”、“z”};
私有字符串[]所有单词={“应用程序”、“苹果”、“安卓”、“贝塔”、“布朗”、“奶牛”、“营地”、“下降”、“挖掘”、“大象”、“eclair”、“失败”、“满”、“消失”、“得到”、“如何”、“蜂蜜”、“生病”、“冰”、“慢跑”、“旅程”、“国王”、“袋鼠”、“柠檬”、“龙虾”、“马克”、“制造”、“鼻子”、“无”、“原产地”、“八达通”、“力量”、“拾取”、“象限”、“尊重”、“跑步”、“太阳”、“看见”、“吨”、“谭”,“在”、“无法”、“视图”、“维纳斯”、“什么”、“哪里”、“是”、“哈欠”、“斑马”};
@抑制警告(“未使用”)
专用按钮生成按钮;
私人编辑文本最少;
私人编辑文本最大值;
私人信件;
私人复选框词;
私人支票号码;
私有文本密码;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.generateButton=(按钮)this.findViewById(R.id.generate);
this.minimum=(EditText)this.findViewById(R.id.min);
this.max=(EditText)this.findViewById(R.id.max);
this.letters=(复选框)this.findViewById(R.id.letters);
this.words=(复选框)this.findViewById(R.id.words);
this.numbers=(复选框)this.findViewById(R.id.numbers);
this.password=(EditText)this.findViewById(R.id.password);
}
公共void生成(视图v)
{
字符串mi=minimum.getText().toString();
字符串ma=maxium.getText().toString();
Boolean num=数字。isChecked();
布尔let=字母.isChecked();
布尔词=words.isChecked();
String new_password=make_password(mi、ma、num、let、word);
password.setText(新密码);
}
@抑制警告(“最终”)
公共字符串生成密码(字符串最大值、字符串最小值、布尔数、布尔字母、布尔字)
{
字符串密码=新字符串(“”);
int最小值=0;
int最大值=0;
尝试
{
最小值=整数.parseInt(最小值);
最大值=整数.parseInt(最大值);
}
捕获(可丢弃的t)
{
password=“必须将最小值和最大值都设置为整数!”;
}
最后
{
//如果(数字==true)密码+=“数字,”;
//如果(字母==true)密码+=“字母,”;
//如果(words==true)密码+=“words.”;
Random_gen=新随机();
int length=minimum+(int)(Math.random()*(maximum-minimum));
//密码+=整数.toString(长度);
//密码+=“:”;
如果(数字==false&&letters==true&&words==false)
{
while(长度!=0)
{
密码+=所有字母[random_gen.nextInt(26)];
长度-=1;
}
}
如果(数字==false&&letters==false&&words==true)
{
如果(长度3)
{
选择的字符串\u单词=所有单词[随机\u gen.nextInt(所有单词.长度)];
如果(已选择单词长度()3)
{
选择的字符串\u单词=所有单词[随机\u gen.nextInt(所有单词.长度)];
如果(已选择单词长度()3)
{
选择的字符串\u单词=所有单词[随机\u gen.nextInt(所有单词.长度)];
如果(已选择单词长度()3)
{
选择的字符串\u单词=所有单词[随机\u gen.nextInt(所有单词.长度)];

如果(所选单词长度()在你的清单中,你说你的应用程序的android:name是Passerator。但是,Passerator是一个活动,而不是一个应用程序。根据,name属性应该引用应用程序子类的完全限定名。

你能发布完整的logcat输出吗?你在你的android清单中缺少起始标记吗?谢谢,可以这样做成功了!这是我的第一个程序,我很高兴它能为你成功!在Stackoverflow上,你应该通过勾选答案旁边的复选框来标记你问题的“正确”答案。这样,未来的读者就会知道什么是有效的。