InstantiationException, newInstance failed: no <init>, while there is only default constructor in Activity

1.7k views Asked by At

We received stack trace of InstantiationException while creating instance of Activity. Log has newInstance failed: no <init>() message

The situation is quite clear: VM can't find default parameterless constructor. This is explained in this thread

As my research shown people usually receive this when they add parameters to constructors of their Activities, which definitely is bad. But this is not our case - we always have access to default constructor. Another reason of that exception could be another exception while initializing some member(initialiation is run in default constructor, right?) - but again we don't do that. All members are initialized in onCreate() method.

Some details(names changed): activity is added to AndroidManifest.xml:

<manifest
    package="app.name"
    ....>
    ....
    <activity
        android:name="app.name.activity.OurActivity"
        android:label="@string/NAME">
    </activity>

Now the way that we create the intent may look strange, but it works in every case:

Context packageContext = layoutInflater.getContext().createPackageContext("app.name", 0);
Intent intent = new Intent(packageContext, OurActivity.class);
...startActivity(intent);

I would think that this could be a problem, but: 1) this works fine for months 2) same client got same exception in another activity which is start using activity as a context;

I can't reproduce the exception to understand/fix it. But somehow one of our clients got it. He has Droid ERIS(Verizon) device

Any thoughts? Is there any case I don't know about when VM will not find the default constructor?

0

There are 0 answers