修改了AndroidManifest.xml,设置的属性android:name="自定义的Aplication",结果运行Android项目,报下面错误:
 

    08-18 02:27:41.660: D/dalvikvm(649): newInstance failed: Lcom/foxhis/untils/ActivityApplication;.() not accessible to Landroid/app/Instrumentation;  
    08-18 02:27:41.660: D/AndroidRuntime(649): Shutting down VM  
    08-18 02:27:41.660: W/dalvikvm(649): threadid=1: thread exiting with uncaught exception (group=0x4001d800)  
    08-18 02:27:41.680: E/AndroidRuntime(649): FATAL EXCEPTION: main  
    08-18 02:27:41.680: E/AndroidRuntime(649): java.lang.RuntimeException: Unable to instantiate application com.foxhis.untils.ActivityApplication: java.lang.IllegalAccessException: access to constructor not allowed  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649) 
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread.access$3000(ActivityThread.java:125)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.os.Handler.dispatchMessage(Handler.java:99)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.os.Looper.loop(Looper.java:123)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread.main(ActivityThread.java:4627)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at java.lang.reflect.Method.invokeNative(Native Method)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at java.lang.reflect.Method.invoke(Method.java:521)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
    08-18 02:27:41.680: E/AndroidRuntime(649):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at dalvik.system.NativeStart.main(Native Method)  
    08-18 02:27:41.680: E/AndroidRuntime(649): Caused by: java.lang.IllegalAccessException: access to constructor not allowed  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at java.lang.Class.newInstanceImpl(Native Method)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at java.lang.Class.newInstance(Class.java:1429)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.Instrumentation.newApplication(Instrumentation.java:957)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.Instrumentation.newApplication(Instrumentation.java:942)  
    08-18 02:27:41.680: E/AndroidRuntime(649):  at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644) 
    08-18 02:27:41.680: E/AndroidRuntime(649):  ... 11 more  

错误提示是,构造方法的权限不对,招拒。

 

检查了整个Application,才发现,原来有一个无参数的构造方法,被设计成private。

修改其为public即可。

 

其他:

      对于自定义的Application,如果里面定义的参数是,只仅仅该类中使用,则可以定义为private,私有属性。 如果是其他地方也使用,必须定义为public。 类中方法,全部定义为public。


转自:http://www.cxybl.com/html/android/20140818/41145.html

更多相关文章

  1. android标题栏进度圈使用方法
  2. Android重写onOreate,onPause,onStop等方法时需要注意的问题!
  3. XML解析
  4. android 比较有用的方法总结
  5. Android(安卓)Studio 0.6.1 中 gradle 构建 异常
  6. System.EntryPointNotFoundException: Unable to find an entry
  7. 【Android(安卓)开发教程】WebView
  8. android 设置LinearLayout,RelativeLayout等等layout的高和宽
  9. Android(安卓)View(四)-View相关属性详解

随机推荐

  1. 自己编写Android手电筒,支持5.0
  2. android通知栏消息
  3. Android开发:Android快速开发不可或缺的11
  4. Android保存图片到系统相册
  5. Android(安卓)调试桥(adb)
  6. 复习TextView(查漏补缺)
  7. 移植rtmpdump(librtmp)到android
  8. Android深入浅出之Audio
  9. 【Android 应用开发】 Android APK 反编
  10. NCNN: 应用于手机上的卷积加速