Skip to content

Android app builds but crashes on Launch after Latest VS Update #4470

Closed

Description

@sereoja

Steps to Reproduce

  1. Installed latest VS2019 stable Update on Mac
  2. Multidex enabled, D8 true, R8 true
  3. 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

  1. sereoja commented on Mar 27, 2020

    @sereoja
    Author

    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

  2. bolk commented on Mar 30, 2020

    @bolk

    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.

  3. sereoja commented on Mar 30, 2020

    @sereoja
    Author

    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.

    <application 
    android:label="App Name" 
    android:theme="@style/splashscreen" 
    android:icon="@mipmap/ic_launcher">
    

    I removed these parameters
    android:hardwareAccelerated="true"
    launchMode="singleTop"
    android:largeHeap="true"
    android:allowBackup="false"
    android:hasCode="false"

  4. brendanzagaeski commented on Mar 30, 2020

    @brendanzagaeski
    Contributor

    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 be true (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.

  5. brendanzagaeski commented on Mar 30, 2020

    @brendanzagaeski
    Contributor

    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!

  6. added
    need-info
    on Mar 30, 2020
  7. bolk commented on Mar 30, 2020

    @bolk

    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:

    [BT : 0.10.2] error : Module 'base' has no dex files but the attribute 'hasCode' is not set to false in the AndroidManifest.xml.

    If I add it as android:hasCode="false" it builds, but the deploy runs but the application crashes with message:

    [AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application crc64117ee1069bfbf50b.MainApplication: java.lang.ClassNotFoundException: Didn't find class "crc64117ee1069bfbf50b.MainApplication" on path...

    If I rollback to Android.Xamarin 10.1.3.7, without the android:hasCode attribute, everything works fine.

    Regards,
    Alberto

  8. sereoja commented on Mar 30, 2020

    @sereoja
    Author

    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

  9. brendanzagaeski commented on Mar 31, 2020

    @brendanzagaeski
    Contributor

    @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:

    1. Set Visual Studio > Preferences > Projects [section] > Build [subsection] > Log verbosity to Diagnostic.
    2. Clean and deploy the app project again.
    3. Open the View > Pads > Errors window. Click on the Build Output button to show the build output.
    4. Copy and paste all of the output from that window into a text file.
    5. Open the View > Pads > Deploying to Device window.
    6. Copy and paste all of the output from that deployment window into a text file too. (You can paste it at the end of the same text file from step 4 if you like.)
    7. Zip up and attach the text file(s) on the new issue.

    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!

  10. brendanzagaeski commented on Apr 3, 2020

    @brendanzagaeski
    Contributor

    [BT : 0.10.2] error : Module 'base' has no dex files but the attribute 'hasCode' is not set to false in the AndroidManifest.xml.

    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!

  11. removed
    need-info
    on Apr 3, 2020
  12. ghost locked as resolved and limited conversation to collaborators on Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions