Android: java.lang.IllegalAccessException when attempting to use a custom “Application” class

后端 未结 2 948
再見小時候
再見小時候 2020-12-05 22:58

I\'m trying to create define a custom Application class as follows:

  1. create an empty subclass of Application called MyApp
  2. in the manifest, specify andr
相关标签:
2条回答
  • 2020-12-05 23:19

    Make sure your custom class is public, has a public zero-argument constructor, and that the constructor chains to the superclass' constructor.

    0 讨论(0)
  • 2020-12-05 23:26

    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.

    0 讨论(0)
提交回复
热议问题