I'm trying to create define a custom Application class as follows:
<application android:name=".MyApp"
...
However, when I attempt to run my app, I get:
java.lang.RuntimeException: Unable to instantiate application com.test.MyApp java.lang.IllegalAccessException: access to class not allowed
Make sure your custom class is public
, has a public
zero-argument constructor, and that the constructor chains to the superclass' constructor.
I agree with CommonsWare. If you extend android.app.Application to define custom application for your project, make sure that you have marked your class as public and public no-agrs constructor as well.
However, on android.app.Application API its mentioned that, There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way.
Hope this will help.
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With