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

后端 未结 2 949
再見小時候
再見小時候 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: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.

提交回复
热议问题