首页 > 代码库 > AccessibilityService ClassNotFoundExcepiton
AccessibilityService ClassNotFoundExcepiton
今天在学习AccessiblityService,简单的几部操作,但是当辅助功能里开启服务时一直报ClassNotFoundException,异常如下(写这篇blog时,错误信息已经没了,从网上直接找粘贴的一个,错误信息跟我的一样):
so,赶快重新建了一个项目,创建项目的时候直接创建一个类,也就是创建一个和应用包名一样的package
FATAL EXCEPTION: main Process: com.edr.iveflownthat, PID: 1457 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/edr/iveflownthat/TempLobbyActivity; at com.edr.iveflownthat.pages.MainActivity.tryAutoLogin(MainActivity.java:46) at com.edr.iveflownthat.pages.MainActivity.onCreate(MainActivity.java:22) at android.app.Activity.performCreate(Activity.java:5933) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.edr.iveflownthat.TempLobbyActivity" on path: DexPathList[[zip file "/data/app/com.edr.iveflownthat-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] FATAL EXCEPTION: main Process: com.edr.iveflownthat, PID: 1457 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/edr/iveflownthat/TempLobbyActivity; at com.edr.iveflownthat.pages.MainActivity.tryAutoLogin(MainActivity.java:46) at com.edr.iveflownthat.pages.MainActivity.onCreate(MainActivity.java:22) at android.app.Activity.performCreate(Activity.java:5933) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.edr.iveflownthat.TempLobbyActivity" on path: DexPathList[[zip file "/data/app/com.edr.iveflownthat-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 15 more Suppressed: java.lang.NoClassDefFoundError: com.edr.iveflownthat.TempLobbyActivity at dalvik.system.DexFile.defineClassNative(Native Method) at dalvik.system.DexFile.defineClass(DexFile.java:222) at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215) at dalvik.system.DexPathList.findClass(DexPathList.java:321) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) ... 17 more Suppressed: java.lang.ClassNotFoundException: com.edr.iveflownthat.TempLobbyActivity at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 16 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 15 more Suppressed: java.lang.NoClassDefFoundError: com.edr.iveflownthat.TempLobbyActivity at dalvik.system.DexFile.defineClassNative(Native Method) at dalvik.system.DexFile.defineClass(DexFile.java:222) at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215) at dalvik.system.DexPathList.findClass(DexPathList.java:321) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) ... 17 more Suppressed: java.lang.ClassNotFoundException: com.edr.iveflownthat.TempLobbyActivity at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 16 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available最后,突发灵感,想到我在创建项目时,没有像往常一样直接创建一个MainActivity.java,创建项目之后重新创建了一个和应用包名一样的package,在里面放置我的类,致使在调用的时候找不到我的类,不知道为什么这么做不行,但是知道错误的原因了。
so,赶快重新建了一个项目,创建项目的时候直接创建一个类,也就是创建一个和应用包名一样的package
AccessibilityService ClassNotFoundExcepiton
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。