3

this is a follow-up question to my question earlier this day.

I have installed the compatibility pack and restarted Eclipse. Then I created an activity like this, using Blundell's code:

public class EntryActivitiy extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);

        int b = Integer.parseInt(Build.VERSION.SDK);
        if (b >= Build.VERSION_CODES.HONEYCOMB)
        {
            Log.i(getString(R.string.app_name), "Found A Tablet Running Honeycomb or newer");
            //nothing else in here yet
        }
        else
        {
            this.startActivity(new Intent(this, Main.class));
        }
    }

}

My Manifest contains:

 <uses-sdk android:minSdkVersion="8" 
        android:targetSdkVersion="11"/>

    <supports-screens android:smallScreens="false"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

as well as

    <activity android:name="EntryActivity"
        android:label="@string/app_name" 
        android:noHistory="true">           

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

In the project settings, I have set the build target to 3.0 as otherwise I'll get an "HONEYCOMB cannot be resolved or is not a field" error.

Now, if I run it on my 2.2 AVD, the app crashes like this:

05-27 14:13:54.270: ERROR/AndroidRuntime(329): FATAL EXCEPTION: main
05-27 14:13:54.270: ERROR/AndroidRuntime(329): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{/myPackage.EntryActivity}: java.lang.ClassNotFoundException: myPackage.EntryActivity in loader dalvik.system.PathClassLoader[/data/app/myPackage-1.apk]
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.os.Looper.loop(Looper.java:123)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at java.lang.reflect.Method.invokeNative(Native Method)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at java.lang.reflect.Method.invoke(Method.java:521)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at dalvik.system.NativeStart.main(Native Method)
05-27 14:13:54.270: ERROR/AndroidRuntime(329): Caused by: java.lang.ClassNotFoundException: myPackage.EntryActivity in loader dalvik.system.PathClassLoader[/data/app/myPackage-1.apk]
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-27 14:13:54.270: ERROR/AndroidRuntime(329):     ... 11 more

If tried it on my 2.3 phone but got some weird screen flickering and "HDMI disconnected" and other very strange messages in the LogCat. I don't want to repeat it, though, so I can't provide the exact messages.

What am I doing wrong?

Kind regards, jellyfish

Edit:

I swapped back to my old main activity and it worked fine. Also, I commented all the HC-related code out and it still would crash. I also tried to set another Activity as main and that also worked. :/

Community
  • 1
  • 1
jellyfish
  • 7,868
  • 11
  • 37
  • 49

3 Answers3

1

What's the package of EntryActivity? Is it in myPackage?

Kaj
  • 10,862
  • 2
  • 33
  • 27
  • Have you checked if the file is in /data/app/myPackage-1.apk? Have you done a rebuild and deploy? – Kaj May 27 '11 at 14:53
  • I did a rebuild, yes. Where can I find /data/app ? I only have /res, /src etc. – jellyfish May 27 '11 at 14:57
  • You should hopefully be able to find it in the emulator or on the phone. You can "ssh" to the phone by using `adb shell` from the command line. – Kaj May 27 '11 at 15:04
1

You need to place a period before the class name of your activity in the manifest:

 <activity android:name=".EntryActivity"
mportuesisf
  • 5,587
  • 2
  • 33
  • 26
  • 1
    I was going to say your missing the period. Have you done a Project > Clean and it should Auto rebuild after this? – Blundell May 27 '11 at 15:10
  • I did. I'm going to try if restarting Eclipse helps. I have to leave now, though, so I can't try today. At least I know after some testing that it's not the Honeycomb stuff. ;) – jellyfish May 27 '11 at 15:14
  • Jelly the answer is in .. my answer :p check your spellings ;-) – Blundell May 27 '11 at 15:16
1

EDIT

Your activity class is actually Misspelt!

Change it in your manifest or change your class name:

 public class EntryActivitiy extends // here spellcheck

Original Answer

You need a period before the class name of your activity in your manifest:

 <activity android:name=".EntryActivity"
    android:label="@string/app_name" 
    android:noHistory="true">  

Do a Project > Clean and it should Auto rebuild after this

You then need to check your manifest to ensure your package is correct:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.something.something"
 ....

I would also uninstall off the emulator after this, just to be safe , Emulator > Settings > Applications > Standard Uninstall

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • oh no, seriously...? that's happening when you're supposed to go home but try to get something working instead. ^^ Thank you ever so much, that was really tricky to spot! :) – jellyfish May 30 '11 at 07:40