Do I know if I need Multi-Dex enabled? (ClassNotFo

2019-01-04 14:48发布

Suddenly and seemingly for no reason at all, the following error starts presenting itself. After fighting it all day, I discovered enabling Multi-Dex resolved it. Is this error potentially caused by my breaching the 64k reference threshold?

java.lang.RuntimeException: Unable to instantiate application md52323d240c954a07dbdbeb3f1c41a0cab.MainApplication: java.lang.ClassNotFoundException: Didn't find class "md52323d240c954a07dbdbeb3f1c41a0cab.MainApplication" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/arm64, /data/app/com.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:823)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5529)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1576)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6281)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Somewhere I can see the count of references? How do I know if I surpassed this - in VS specifically?

enter image description here

2条回答
成全新的幸福
2楼-- · 2019-01-04 15:16

java.lang.ClassNotFoundException: Didn't find class

This is a known issue in the creation of the Java classes.zip file in the following release:

December 4th, 2017 - Xamarin.Android 8.1.0.24

  • This version is included in the Visual Studio 2017 version 15.5 release.

Java.lang.ClassNotFoundException

We have had multiple reports regarding applications running into a "Java.Lang.ClassNotFoundException: Didn't find class on path: DexPathList" exception.

Bug: xamarin.android_8.1/#Known_Issues

GitHub PR fix: https://github.com/xamarin/xamarin-android/pull/1142

Workaround:

You can clean/rebuild as a workaround on Windows in order to recreate the Java classes.zip file

查看更多
家丑人穷心不美
3楼-- · 2019-01-04 15:26

First, you can count the method references (and see other useful insight) using the APK Analyzer tool. It is shipped with Android Studio; you can find it under the Build menu and it's also available from the command line with apkanalyzer.

Second, you will get a build error indicating you need to use multi dex. It looks like:

trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option.

More here: https://developer.android.com/studio/build/multidex.html

查看更多
登录 后发表回答