zoukankan      html  css  js  c++  java
  • java.lang.IllegalAccessException: access to class not allowed

    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)
    -----------------------------------

    以上是错误日志信息

    我的错误是写class 文件是时候没有把class设置成public

    我把原来的class MainActivity 改成 public class MainActivity

    再重新运行就可以了

    文章来源: 

    java.lang.IllegalAccessException: access to class not allowed 错误解决方法

  • 相关阅读:
    自适应网页设计(Responsive Web Design)(转)
    PAT 1062 最简分数(20)(代码+思路)
    PAT 1059 C语言竞赛(20)(代码+思路)
    PAT 1058 选择题(20)(代码+思路)
    PAT 1057 数零壹 (20)(代码+思路)
    PAT 1054 求平均值 (20)(代码+思路+测试用例)
    PAT 1053 住房空置率 (20)(代码+思路)
    PAT 1052 卖个萌 (20)(代码+思路)
    PAT 1048 数字加密(20)(代码+思路)
    PAT 1047 编程团体赛(代码)
  • 原文地址:https://www.cnblogs.com/xsgame/p/3065896.html
Copyright © 2011-2022 走看看