0

I have updated my app today and after that I got 12 crash reports. As i can see all are tide to my main activity class. Here's couple of them:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{rs.androidaplikacije.zastaveigradovi/rs.androidaplikacije.zastaveigradovi.MainActivity}: java.lang.ClassNotFoundException: rs.androidaplikacije.zastaveigradovi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/rs.androidaplikacije.zastaveigradovi-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: rs.androidaplikacije.zastaveigradovi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/rs.androidaplikacije.zastaveigradovi-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
... 11 more


java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{rs.androidaplikacije.zastaveigradovi/rs.androidaplikacije.zastaveigradovi.MainActivity}: java.lang.ClassNotFoundException: rs.androidaplikacije.zastaveigradovi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/rs.androidaplikacije.zastaveigradovi-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1664)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1766)
at android.app.ActivityThread.access$1500(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
at android.os.Handler.dispatchMessage(Handler.java:130)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3833)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: rs.androidaplikacije.zastaveigradovi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/rs.androidaplikacije.zastaveigradovi-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:271)
at java.lang.ClassLoader.loadClass(ClassLoader.java:582)
at java.lang.ClassLoader.loadClass(ClassLoader.java:542)
at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1656)
... 11 more

And here's my main activity. I did not change anything in it at all.

public class MainActivity extends SwarmActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        preload(this, 5259, "0d2ab20831857f730c1c362705970d1f");
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        Thread splashTimer = new Thread(){
            public void run(){
                try {
                    sleep(2000);
                    Intent menuIntent = new Intent("rs.androidaplikacije.zastaveigradovi.MENU");
                    startActivity(menuIntent);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                finally{
                    finish();
                }
            }
        };
        splashTimer.start();
    }

    private void preload(MainActivity mainActivity, int i, String string) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

Everything works fine on my phone, but i got a lot of crash reports today. Can someone tell me what's the problem?

3
  • Could you post the manifest file? Commented May 12, 2013 at 0:24
  • What is the full inheritance of SwarmActivity? If any of the superclasses depend on a class that doesn't exist on someone's phone, then this error will be thrown. If they merely REFER to another class, the class can't load. (worst case: you may have to use dynamic class loading via reflection). Commented May 12, 2013 at 1:17
  • I just import com.swarmconnect.SwarmActivity;. It's online leaderboard service. Commented May 12, 2013 at 1:33

1 Answer 1

2

I think that the problem is in the way your application is "packaged". The exception is saying that the class loader cannot find the rs.androidaplikacije.zastaveigradovi.MainActivity class when it tries to load it. The fact that you didn't change your code is probably not relevant.

Why it works on your phone and not on other peoples' is less clear. But it could be that:

  • The version you are running on your phone is not identical to the one that other people are getting from the app store (or wherever).
  • Your phone has other stuff on it, and that other stuff is what makes the difference.

(It is also possible that the root cause is earlier than the exception in the reports. On a real Java platform, it is possible for class loading and initialization to fail, leaving some classes in an unintializable state. This can then cause later things to fail to load. In this case, the later exceptions don't tell you the real cause of the problems. You have to look to the earlier exception stacktraces for the real cause. HOWEVER, I don't think that is what is happening here.)

Sign up to request clarification or add additional context in comments.

2 Comments

When I install it over Eclipse it works fine, when I install it over Play Store it crashes on start.
Well at least you can reproduce the problem now!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.