>  기사  >  데이터 베이스  >  Android报java.lang.IllegalAccessException: access to class n

Android报java.lang.IllegalAccessException: access to class n

WBOY
WBOY원래의
2016-06-07 15:50:001510검색

06-27 04:48:02.123: ERROR/AndroidRuntime(787): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.android.surfacetest/net.android.surfacetest.MainActivity}: java.lang.IllegalAccessException: access to class not al

06-27 04:48:02.123: ERROR/AndroidRuntime(787): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.android.surfacetest/net.android.surfacetest.MainActivity}: java.lang.IllegalAccessException: access to class not allowed
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.os.Looper.loop(Looper.java:123)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at java.lang.reflect.Method.invokeNative(Native Method)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at java.lang.reflect.Method.invoke(Method.java:507)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at dalvik.system.NativeStart.main(Native Method)
06-27 04:48:02.123: ERROR/AndroidRuntime(787): Caused by: java.lang.IllegalAccessException: access to class not allowed
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at java.lang.Class.newInstanceImpl(Native Method)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at java.lang.Class.newInstance(Class.java:1409)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-27 04:48:02.123: ERROR/AndroidRuntime(787):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)

Android出现以上是错误日志信息

原因1:Activity没有注册

原因2:包名不匹配

原因3:类不是public的,在报错类的定义前加public即可。

其中原因1和3是最常见的

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.