I got several crash reports with the following stack traces (names changed):
Caused by: java.lang.InstantiationException: can't instantiate class com.example.MyApplication; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newApplication(Instrumentation.java:997)
at android.app.Instrumentation.newApplication(Instrumentation.java:982)
at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
... 11 more
java.lang.RuntimeException: Unable to instantiate application com.example.MyApplication: java.lang.InstantiationException: can't instantiate class com.example.MyApplication; no empty constructor
at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
android.app.Application has an explicit constructor without parameters:
public Application() {
super(null);
}
MyApplicationinherits from android.app.Applicationand generally has no explicit constructors. According to my understanding of the Java specification, this means that the following constructor must be implicitly inserted by the compiler:
public MyApplication() {
super();
}
This should have happened, or I could never have compiled the application in the first place. So what can cause these failures?
<h / "> EDIT: Here is part of the result of decompiling ProGuard-ed MyApplication.classwith javap:
Compiled from "MyApplication.java"
public class com.example.MyApplication extends android.app.Application {
public com.example.MyApplication();
Signature: ()V
public void onCreate();
Signature: ()V
public void onLowMemory();
Signature: ()V
public void onTrimMemory(int);
Signature: (I)V
static {};
Signature: ()V
}
The default constructor is definitely there, and it is open.