我有一個已發佈的應用程序,可以從用戶那裏獲取有關ClassNotFoundException
的報告,這些應用程序超出了我的想法。我一直無法重現此崩潰,此類錯誤的類似實例在SO上有或者是不正確的路徑到MainActivity
中的依賴項或不同的包。Android:罕見和不可複製ClassNotFoundException
錯誤的依賴路徑的問題是Eclipse的問題,而所有其他的錯誤可以通過Android Studio的「同步」和「乾淨的項目」(我沒有用)很容易解決。
我已經三重檢查了所有包名,沒有發現任何差異。
這裏是我的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.johan.fsc">
<uses-permission android:name = "android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:fullBackupContent="true">
<activity
android:name="com.johan.fsc.MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/splashscreenTheme"
android:hardwareAccelerated="false"
android:largeHeap="true">>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name = "com.johan.fsc.SettingsActivity"
android:theme="@style/PreferencesTheme"/>
</application>
以下是錯誤報告,我總是從用戶獲得:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.johan.fsc/com.johan.fsc.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.johan.fsc.MainActivity" on path: DexPathList[[zip file "/data/app/com.johan.fsc-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5624)
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:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.johan.fsc.MainActivity" on path: DexPathList[[zip file "/data/app/com.johan.fsc-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)
at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
... 10 more
Suppressed: java.io.IOException: Failed to open oat file from dex location '/data/app/com.johan.fsc-1/base.apk'
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:295)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:262)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:231)
at dalvik.system.DexPathList.<init>(DexPathList.java:109)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:57)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:370)
at android.app.LoadedApk.makeApplication(LoadedApk.java:562)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4818)
at android.app.ActivityThread.access$1500(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
... 7 more
Caused by: java.io.IOException: Failed to open oat file from /data/app/com.johan.fsc-1/arm/base.odex (error Failed to open oat filename for reading: No such file or directory) (no dalvik_cache availible) and relocation failed.
... 22 more
Caused by: java.io.IOException:
... 22 more
Caused by: java.io.IOException: Failed to remove obsolete file from /data/dalvik-cache/arm/[email protected]@[email protected]@classes.dex when searching for dex file /data/app/com.johan.fsc-1/base.apk: Permission denied
... 22 more
Suppressed: java.lang.ClassNotFoundException: com.johan.fsc.MainActivity
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)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available/output.
這似乎是罪魁禍首就是java.io.IOException: Failed to remove obsolete file from /data/dalvik-cache/arm/[email protected]@[email protected]@classes.dex when searching for dex file /data/app/com.johan.fsc-1/base.apk: Permission denied
,但我有沒有發現爲什麼它被某些用戶調用,而不是大多數,更重要的是 - 如何解決它。
這可能與[安裝不成功](http:// stackoverflow。com/questions/36314269/android-app-users-get-installation-unsuccessful-after-introduced-billing-perm)問題基於這樣一句話:'無法刪除過時的文件...權限被拒絕' –
我也是一直認爲可能存在連接,但我認爲安裝程序實際上並未使用清單中定義的權限。 –
您是否曾嘗試在重新安裝前從設備上卸載應用程序? –