Repository navigation
Description
Steps to Reproduce
- Installed latest VS2019 stable Update on Mac
- Multidex enabled, D8 true, R8 true
- Project build Successfully but Crashes on Launch
Expected Behavior
App to build and Launch
Actual Behavior
App Builds successfully but Crashes on Launch:
Application Output:
[thbrothersfarm] Not late-enabling -Xcheck:jni (already on)
[thbrothersfarm] Unknown bits set in runtime_flags: 0x8000
[thbrothersfarm] Unexpected CPU variant for X86 using defaults: x86
[System] ClassLoader referenced unknown path:
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.xxxxxxxx.xxxxxx, PID: 13719
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application androidx.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "androidx.multidex.MultiDexApplication" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.xxxx.xxxxx-xxxx==/lib/x86, /data/app/com.xxxxxx.xxxx-xxxxx==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
[AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
[AndroidRuntime] at android.app.ActivityThread.access$1300(ActivityThread.java:219)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:107)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:214)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:7356)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.multidex.MultiDexApplication" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.xxxxxxx.xxxxxxxx-xxxxxx==/lib/x86, /data/app/com.xxxxx.xxxxxxx-xxxxxxx==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[AndroidRuntime] at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
[AndroidRuntime] at android.app.Instrumentation.newApplication(Instrumentation.java:1148)
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
[AndroidRuntime] ... 9 more
Version Information
Log File
=== Visual Studio Community 2019 for Mac ===
Version 8.5 (build 3183)
Installation UUID: 55a3511c-ef7f-4dd4-88df-b95b248cf30b
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.14.1.39 (d16-5 / 30e8706b4)
Package version: 608000123
=== Mono Framework MDK ===
Runtime:
Mono 6.8.0.123 (2019-10/1d0d939dc30) (64-bit)
Package version: 608000123
=== Roslyn (Language Service) ===
3.5.0-beta4-20125-04+1baa0b3063238ed752ad1f0368b1df6b6901373e
=== NuGet ===
Version: 5.4.0.6315
=== .NET Core SDK ===
SDK: /usr/local/share/dotnet/sdk/3.1.200/Sdks
SDK Versions:
3.1.200
3.1.102
3.1.101
3.1.100
3.0.101
3.0.100
2.1.701
2.1.700
2.1.505
2.1.504
2.1.503
2.1.500
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Sdks
=== .NET Core Runtime ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.2
3.1.1
3.1.0
3.0.1
3.0.0
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12
2.1.11
2.1.9
2.1.8
2.1.7
2.1.6
=== Xamarin.Profiler ===
Version: 1.6.13.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Apple Developer Tools ===
Xcode 11.4 (16134)
Build 11E146
=== Xamarin.Mac ===
Version: 6.14.1.39 (Visual Studio Community)
Hash: 30e8706b4
Branch: d16-5
Build date: 2020-02-20 16:41:47-0500
=== Xamarin.iOS ===
Version: 13.14.1.39 (Visual Studio Community)
Hash: 30e8706b4
Branch: d16-5
Build date: 2020-02-20 16:41:48-0500
=== Xamarin Designer ===
Version: 16.5.0.471
Hash: 35aa4889d
Branch: remotes/origin/d16-5
Build date: 2020-02-25 00:52:08 UTC
=== Xamarin.Android ===
Version: 10.2.0.100 (Visual Studio Community)
Commit: xamarin-android/d16-5/988c811
Android SDK: /Users/sungureanu/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.4 (API level 19)
5.0 (API level 21)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2
Build Information:
Mono: c0c5c78
Java.Interop: xamarin/java.interop/d16-5@fc18c54
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/sungureanu/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android SDK Manager ===
Version: 16.5.0.39
Hash: 6fb4c79
Branch: remotes/origin/d16-5
Build date: 2020-02-20 23:25:56 UTC
=== Android Device Manager ===
Version: 16.5.0.71
Hash: 49194e8
Branch: remotes/origin/d16-5
Build date: 2020-02-20 23:26:18 UTC
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 805003183
Git revision: 60e06e010baa677204535600661dda3fb4677c2f
Build date: 2020-03-20 06:18:03-04
Build branch: release-8.5
Xamarin extensions: 60e06e010baa677204535600661dda3fb4677c2f
=== Operating System ===
Mac OS X 10.15.4
Darwin 19.4.0 Darwin Kernel Version 19.4.0
Wed Mar 4 22:28:40 PST 2020
root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
Activity
sereoja commentedon Mar 27, 2020
If is set Multi-Dex to False then I get similar error but missing class is different mono.MonoRuntimeProvider vs androidx.multidex.MultiDexApplication
[thbrothersfarm] Not late-enabling -Xcheck:jni (already on)
[thbrothersfarm] Unknown bits set in runtime_flags: 0x8000
[thbrothersfarm] Unexpected CPU variant for X86 using defaults: x86
[System] ClassLoader referenced unknown path:
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.xxxxx.xxxxx, PID: 2515
[AndroidRuntime] java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.ClassNotFoundException: Didn't find class "mono.MonoRuntimeProvider" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.xxxxxx.xxxxxxx-xxxxxxxx==/lib/x86, /data/app/com.xxxxxxxx.xxxxxx-xxxxxxx==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
[AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
[AndroidRuntime] at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
[AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
[AndroidRuntime] at android.app.ActivityThread.access$1300(ActivityThread.java:219)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:107)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:214)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:7356)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "mono.MonoRuntimeProvider" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.xxxxxx.xxxx-xxxxxxxx==/lib/x86, /data/app/com.xxxxxx.xxxxxxxx-xxxxxxx==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[AndroidRuntime] at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
[AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:6972)
[AndroidRuntime] ... 10 more
bolk commentedon Mar 30, 2020
I do confirm having the same issue with the same VS environment.
The application built and run correctly before the VS update.
Adding the annotation with the application name on the MainApplication as suggested on SO doesn't solve it.
sereoja commentedon Mar 30, 2020
I got it to work by removing some parameters from AndroidManifest specifically from application tag.
Currently I have only these parameters and it builds and launches ok.
I removed these parameters
android:hardwareAccelerated="true"
launchMode="singleTop"
android:largeHeap="true"
android:allowBackup="false"
android:hasCode="false"
brendanzagaeski commentedon Mar 30, 2020
Thanks for the clues! I can reproduce the issue locally by adding
android:hasCode="false"to the AndroidManifest.xml of a new template app.On the one hand, the crash makes sense because
android:hasCode="false"indicates that the application contains no code. That attribute should betrue(or omitted) for a Xamarin.Android app.What's odd is that it sounds like this worked differently when building with Xamarin.Android 10.1. I'll take a look to see if I can figure out what changed.
brendanzagaeski commentedon Mar 30, 2020
Puzzling. I get the same crash if I build the app using Xamarin.Android 10.1.3.7.
I also tried editing a few different sections of the the AndroidManifest.xml file with the manifest editor to see if Visual Studio 2019 for Mac version 8.5 was somehow setting the
android:hasCode="false"automatically. So far, it hasn't added the attribute.@sereoja, if by chance you might know any other clues about how the
android:hasCode="false"attribute might have changed for your project when updating, be sure to reply black so the team can investigate further. No worries if not though. Now that this issue is on file, it can help any other users who might notice the same behavior. Thanks!bolk commentedon Mar 30, 2020
Hello @brendanzagaeski,
in my case the Android Manifest doesn't have such
android:hasCode="false"attribute.If I add it as
android:hasCode="true"the build fails with the message:If I add it as
android:hasCode="false"it builds, but the deploy runs but the application crashes with message:If I rollback to Android.Xamarin 10.1.3.7, without the
android:hasCodeattribute, everything works fine.Regards,
Alberto
sereoja commentedon Mar 30, 2020
If you have issues with Dx, here are my settings:
Multidex = false
Dex Compiler = d8
Shrinker = r8
and add a file to the project nameWhatever.cfg and set buildAction to ProguardConfiguration
attached is a sample proguard file you could use.
This helped me a lot to fix multidex/r8
r8.txt
brendanzagaeski commentedon Mar 31, 2020
@bolk, in case sereoja's suggestions about adjusting the multidex and R8 settings don't resolve your issue, then if you get a chance to submit a new item with the diagnostic MSBuild output from your project, that would be perfect. The team would be interested to take a closer look at what's happening for your project.
The steps to collect diagnostic MSBuild output are:
Note that the diagnostic MSBuild output does contain environment variables, such as the macOS user name, so if you prefer to keep it private, you can mention that on the new issue, and the team can reach out with some options for ways to share it privately.
Thanks in advance!
brendanzagaeski commentedon Apr 3, 2020
Thanks for submitting the new issue, and thanks for the clue about this error message. That message text would account for why you folks would have tried setting
android:hasCode="false"in AndroidManifest.xml.I'll close this issue accordingly. The work to take care of the error when
android:hasCode="true"will continue in #4486. Thanks!