J'essaie de créer une application Android en utilisant le dernier SDK à partir de fichiers de projet qui n'ont pas été mis à jour depuis 2015. En un peu, j'ai réussi à le construire et à l'installer, mais lorsque je lance l'application, une erreur Je ne trouve pas beaucoup d’informations sur: "Java.io.IOException: aucun fichier dex original trouvé pour l’emplacement dex".
Voici le texte complet de l'erreur:
03-19 23:32:37.418 10121 10121 E AndroidRuntime: Java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.LaunchActivity}: Java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.LaunchActivity" on path: DexPathList[[Zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm, /system/fake-libs, /data/app/com.xxx.xxx-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2604)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2788)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.-wrap12(ActivityThread.Java)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1503)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.os.Handler.dispatchMessage(Handler.Java:102)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.os.Looper.loop(Looper.Java:154)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.main(ActivityThread.Java:6209)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Java.lang.reflect.Method.invoke(Native Method)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:865)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:755)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: Caused by: Java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.LaunchActivity" on path: DexPathList[[Zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm, /system/fake-libs, /data/app/com.xxx.xxx-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.Java:56)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Java.lang.ClassLoader.loadClass(ClassLoader.Java:380)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Java.lang.ClassLoader.loadClass(ClassLoader.Java:312)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.Instrumentation.newActivity(Instrumentation.Java:1094)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2594)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: ... 9 more
03-19 23:32:37.418 10121 10121 E AndroidRuntime: Suppressed: Java.io.IOException: No original dex files found for dex location /data/app/com.xxx.xxx-1/base.apk
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexFile.openDexFileNative(Native Method)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexFile.openDexFile(DexFile.Java:373)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexFile.<init>(DexFile.Java:113)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexFile.<init>(DexFile.Java:78)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexPathList.loadDexFile(DexPathList.Java:359)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexPathList.makeElements(DexPathList.Java:323)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexPathList.makeDexElements(DexPathList.Java:263)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.DexPathList.<init>(DexPathList.Java:126)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.Java:48)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at dalvik.system.PathClassLoader.<init>(PathClassLoader.Java:64)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at com.Android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.Java:43)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.Java:58)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.Java:525)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.LoadedApk.getClassLoader(LoadedApk.Java:558)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.getTopLevelResources(ActivityThread.Java:1902)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.LoadedApk.getResources(LoadedApk.Java:774)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ContextImpl.<init>(ContextImpl.Java:2083)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ContextImpl.createAppContext(ContextImpl.Java:2028)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.handleBindApplication(ActivityThread.Java:5383)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread.-wrap2(ActivityThread.Java)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1571)
03-19 23:32:37.418 10121 10121 E AndroidRuntime: ... 6 more
Et voici la sortie dex pertinente:
-dex:
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/bin/classes
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_apk_expansion/downloader_library/bin/classes.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_licensing/library/bin/classes.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/crittercism_v1_3_0.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/jackson-mapper-asl-1.8.4.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_apk_expansion/downloader_library/libs/Android-support-v4.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/dropbox-Android-sdk-1.5.4.jar
[dex] input: /Users/alvion/Library/Android/sdk/tools/support/annotations.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/ouya-sdk.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/guava-r09.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/in-app-purchasing-1.0.3.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/jackson-core-asl-1.8.4.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/json_simple-1.1.jar
[dex] input: /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/commons-lang-2.6.jar
[dex] Pre-Dexing /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_apk_expansion/downloader_library/bin/classes.jar -> classes-81c328b1bd235b3a63ab7b7dc3612832.jar
[dex] Using Pre-Dexed classes-8402751112432f9e98dc60e91b59aa39.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_licensing/library/bin/classes.jar
[dex] Using Pre-Dexed crittercism_v1_3_0-3d69c6e931684bd63dfe2e833d0aebe6.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/crittercism_v1_3_0.jar
[dex] Using Pre-Dexed jackson-mapper-asl-1.8.4-ffc362a66f3bc5bb8073e3401c4d7c7b.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/jackson-mapper-asl-1.8.4.jar
[dex] Using Pre-Dexed Android-support-v4-39781f5ab2494414fb73e335497fb91d.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/google/play_apk_expansion/downloader_library/libs/Android-support-v4.jar
[dex] Using Pre-Dexed dropbox-Android-sdk-1.5.4-e975c3510f4992bd1ed860294caaaec6.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/dropbox-Android-sdk-1.5.4.jar
[dex] Using Pre-Dexed annotations-812d332b38fbdb408dd663820ddaf9f6.jar <- /Users/alvion/Library/Android/sdk/tools/support/annotations.jar
[dex] Using Pre-Dexed ouya-sdk-7728ab2d7956de1baa1d2087c8b3543b.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/ouya-sdk.jar
[dex] Using Pre-Dexed guava-r09-e1a6934eeb9a0381c562ff20974676c2.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/guava-r09.jar
[dex] Using Pre-Dexed in-app-purchasing-1.0.3-fa4d8ee5ba37ef3c2e63307e237f5958.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/in-app-purchasing-1.0.3.jar
[dex] Using Pre-Dexed jackson-core-asl-1.8.4-d94d4ec863304731c24c400b1f59e0be.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/jackson-core-asl-1.8.4.jar
[dex] Using Pre-Dexed json_simple-1.1-162e5f2c569f2c90fd6fa9067260bced.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/json_simple-1.1.jar
[dex] Using Pre-Dexed commons-lang-2.6-73a87249d3e4206fda186982d953eb0b.jar <- /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/libs/commons-lang-2.6.jar
[dex] Found modified input file
[dex] Converting compiled files and external libraries into /Users/alvion/df/xxx/xxx/Code/Host-Ant/Game/bin/classes.dex...
[dx] Merged dex #1 (87 defs/139.5KiB)
[dx] Merged dex #2 (371 defs/436.8KiB)
[dx] Merged dex #3 (2 defs/1.1KiB)
[dx] Merged dex #4 (50 defs/90.6KiB)
[dx] Merged dex #5 (25 defs/35.5KiB)
[dx] Merged dex #6 (133 defs/331.3KiB)
[dx] Merged dex #7 (69 defs/199.7KiB)
[dx] Merged dex #8 (73 defs/84.7KiB)
[dx] Merged dex #9 (883 defs/1023.2KiB)
[dx] Merged dex #10 (85 defs/58.1KiB)
[dx] Merged dex #11 (129 defs/232.0KiB)
[dx] Merged dex #12 (432 defs/535.7KiB)
[dx] Merged dex #13 (12 defs/21.8KiB)
[dx] Merged dex #14 (204 defs/181.7KiB)
[dx] Result is 2555 defs/4209.8KiB. Took 0.6s
Quelques détails sur l'application:
Failed to install drm_free/Xxx-debug.apk: Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed reading assets/some/random/asset.bin in Android.util.jar.StrictJarFile@710a502: META-INF/MANIFEST.MF has invalid digest for assets/some/random/asset.bin in assets/some/random/asset.bin]
Le seul problème lié que j'ai pu trouver était celui-ci mais il ne semble pas y avoir de lien, car il y a très peu de code Java dans cette application, aussi atteindre la limite de la méthode dex n'a pas de sens. La solution proposée ici est très simple, car la propriété multiDexEnabled que je dois définir dans mon processus de construction ne semble être exposée que dans le fichier de génération Gradle, ce que je n’ai pas car il s’agit d’un projet hérité.
J'ai eu un problème similaire, solution: Aller àbuild.gradle(Module: app)
indebug
block and disableminifyEnabled
:
debug {
minifyEnabled false
}
Dans mon cas, Paramétrage> Construction, Exécution, Déploiement> Exécution instantanée.
Décochez la case "Activer l'exécution instantanée pour les changements de code/ressource d'échange à chaud lors du déploiement"
A bien fonctionné.
J'ai également rencontré le même genre de problème après l'installation de mon apk. Après avoir désactivé PREOPT d’Android.mk et créé l’application, celui-ci a commencé à fonctionner.
Veuillez consulter le lien ci-dessous pour référence https://groups.google.com/forum/#!topic/Android-building/NWpPusXEfN0
J'ai eu la même erreur, mais il a été découvert que j'avais oublié d'ajouter une permission dans AndroidManifest.xml. Mon application utilise Internet avec une vue Web. J'ai donc besoin de cette permission.
<uses-permission Android:name="Android.permission.INTERNET" />
Il semble également qu’il y ait eu une erreur de nom d’activité dans le fichier manifeste.
<activity Android:name=".(Wrong name)">
Lorsque j'ai corrigé ces erreurs, l'erreur a disparu.
J'ai vu cette erreur en oubliant d'ajouter
<uses-library
Android:name="org.Apache.http.legacy"
Android:required="false" />