views:

84

answers:

1

Whenever I run my program, I get this error:

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

. I have no Idea why!!!! This didn't happen before

!<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>
A: 

In your manifest you say that the android:name of your application is Passerator. However, Passerator is an Activity, not an application. Per the documentation, the name attribute should refer to the fully qualified name of an Application subclass.

Mayra
Thanks, it worked! I was pulling my hair out, as this was my first program!
Eggplant Animation
Glad it worked for you! On Stackoverflow you should mark the "correct" answer to your question by checking the checkbox next to an answer. That way future readers know what worked.
Mayra