Question

I seem to have a tricky problem since the latest ADT update to release 17.

I have made a simple application to illustrate my problem, I don't know if I'm doing anything wrong. The main Activity of my application is inheriting from FragmentActivity in the support package and somehow the application crashes at launch.

To illustrate, I made a sample project.

First of all, here is the code of my dummy class, DummyProjectActivity, very simple:

public class DummyProjectActivity extends FragmentActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Then, there is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="be.emich.labs"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".DummyProjectActivity"
            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>

The .jar file is imported correctly in the project and I am getting this stack trace:

E/AndroidRuntime(11509): FATAL EXCEPTION: main
E/AndroidRuntime(11509): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{be.emich.labs/be.emich.labs.DummyProjectActivity}: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
E/AndroidRuntime(11509):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(11509):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(11509):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(11509):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11509):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(11509):    at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(11509):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11509):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(11509):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(11509):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(11509):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11509): Caused by: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(11509):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(11509):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(11509):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(11509):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
E/AndroidRuntime(11509):    ... 11 more

What am I doing wrong here? Could this be a bug in the latest dev tools?

I am encountering the problem in every project that uses FragmentActivity from the compatibility library. I don't get what could be wrong. Anyone else having this problem? Help would be greatly appreciated. I'm not having the problem with an Activity that inherits from FragmentActivity. I have uninstalled/reinstalled the application. Done various "clean project". Restarted Eclipse.

UPDATE: The issue is apparently not linked to the compatibility package but the way ADT r17 handles linking of jar files. Jars to be included should be put into the libs/ folder and ADT will link them automatically. Otherwise they will be missing from the APK and make the app crash whenever the code from the jarfile is invoked.

Was it helpful?

Solution

Until the latest release tools right click > Add compatibility package on my project wasn't working and I included the jar file manually through the project properties. I tried "Add compatibility package" again and since r17 it seems this is fixed for my machine. This fixed the problem.

OTHER TIPS

http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

I had a lot of trouble too. Just beginning developing and this kind of thing occured hahaha

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top