镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Android app bundle (.aab) crashes on startup when using Android 9.0 emulator #4893

Closed

Description

@codympearson

Steps to Reproduce

  1. Set your Android project as the startup project
  2. Select the Release configuration
  3. In your Android project settings, under Android Build > General, set the package format to aab
  4. Under Advanced, ensure x86 is enabled as a supported ABI
  5. Build and deploy your app to a simulator running Android 9.0 (Pie) - x86
  6. The app freezes on the splash screen (before OnCreate)
  7. Logs show the app is throwing a mono exception, crashing, and restarting

As a note, a crash does not occur on Android 7.1, 8.1, and 10.0.

Expected Behavior

The app does not crash on launch when using aab on Android 9.0.

Actual Behavior

The app crashes on Android 9.0 after a mono exception and appears to freeze on the launch screen.

Version Information

=== Visual Studio Community 2019 for Mac ===

Version 8.6.5 (build 23)
Installation UUID: 569a2032-b97f-4417-8a14-45ffe1b65f41
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 610000104

=== Mono Framework MDK ===

Runtime:
Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
Package version: 610000104

=== Roslyn (Language Service) ===

3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

=== NuGet ===

Version: 5.6.0.6591

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.301/Sdks
SDK Versions:
3.1.301
3.1.300
3.1.200
3.1.101
3.1.100
3.0.101
3.0.100
2.1.701
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.5
3.1.4
3.1.2
3.1.1
3.1.0
3.0.1
3.0.0
2.1.19
2.1.18
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/cpearson/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.1 (API level 25)
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: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/cpearson/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.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

=== Android Device Manager ===

Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

=== Xamarin Designer ===

Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

=== Apple Developer Tools ===

Xcode 11.5 (16139)
Build 11E608c

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

=== Build Information ===

Release ID: 806050023
Git revision: 5289d413b99fddfc20b4ecf3e445ccb822213427
Build date: 2020-06-18 12:08:30-04
Build branch: release-8.6
Xamarin extensions: 5289d413b99fddfc20b4ecf3e445ccb822213427

=== 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

Log File

log.txt

Repro

Repro.zip
log2.txt

Activity

  1. added this to the Under Consideration milestone on Jul 2, 2020
  2. jonathanpeppers commented on Jul 7, 2020

    @jonathanpeppers
    Member

    Maybe @grendello or @brendanzagaeski have seen something like this:

    06-24 10:33:18.622: E/mono(3350): Unhandled Exception:
    06-24 10:33:18.622: E/mono(3350): System.ArgumentNullException: Value cannot be null.
    06-24 10:33:18.622: E/mono(3350): Parameter name: key
    06-24 10:33:18.622: E/mono(3350):   at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <3c2fd5b954804d4fbe58155f333ab55b>:0 
    06-24 10:33:18.622: E/mono(3350):   at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <3c2fd5b954804d4fbe58155f333ab55b>:0 
    06-24 10:33:18.622: E/mono(3350):   at Java.Interop.TypeManager.RegisterType (System.String java_class, System.Type t) [0x0001c] in <cab002740c754a61953d6b361abe0c29>:0 
    06-24 10:33:18.622: E/mono(3350):   at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x0005d] in <cab002740c754a61953d6b361abe0c29>:0 
    06-24 10:33:18.623: E/mono-rt(3350): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
    06-24 10:33:18.623: E/mono-rt(3350): Parameter name: key
    06-24 10:33:18.623: E/mono-rt(3350):   at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <3c2fd5b954804d4fbe58155f333ab55b>:0 
    06-24 10:33:18.623: E/mono-rt(3350):   at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <3c2fd5b954804d4fbe58155f333ab55b>:0 
    06-24 10:33:18.623: E/mono-rt(3350):   at Java.Interop.TypeManager.RegisterType (System.String java_class, System.Type t) [0x0001c] in <cab002740c754a61953d6b361abe0c29>:0 
    06-24 10:33:18.623: E/mono-rt(3350):   at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x0005d] in <cab002740c754a61953d6b361abe0c29>:0 
    

    Is this related to typemaps?

    I don't know why using an app bundle on Android 9.0 would cause this.

    @codympearson do you see this problem on any app (even hello world) or just your app?

  3. codympearson commented on Jul 7, 2020

    @codympearson
    Author

    Hi @jonathanpeppers, I have not tried with a hello world app, but I have seen this issue in two separate Xamarin.Forms applications I am working on currently (one significantly less complex than the other). If I use AAB in debug, both apps run on Android 9.0. Switching to release, AAB crashes on Android 9.0. I have ruled out the AndroidX packages, as the issue occurs on one project that has not migrated yet.

  4. jonathanpeppers commented on Jul 9, 2020

    @jonathanpeppers
    Member

    @codympearson I tried your steps above with the Xamarin.Forms Shell template and it worked for me on an Android 9.0 x86 emulator.

    Is there something specific in your app causing this? Are you able to create a new project that shows the same problem?

    If you enable Mono debug logging for the running emulator via:

    adb shell setprop debug.mono.log debug,assembly,timing
    

    And relaunch the app, it might give more information in the log. Attach that here, thanks!

  5. codympearson commented on Jul 9, 2020

    @codympearson
    Author

    @jonathanpeppers I've uploaded a repro project and log with the requested mono debug logging at the bottom of my post. I created a blank Xamarin.Forms app with Xamarin.Forms 4.6.0, switched the Android project to use AAB in release, ran it, and was able to reproduce the crash. Thanks for looking into this! Here's the interesting piece:

    07-09 14:54:08.806: I/ActivityManager(1918): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.ostusa.app/crc64a17eccbbc6018201.MainActivity bnds=[37,681][238,979]} from uid 10006
    07-09 14:54:08.815: W/audio_hw_generic(1640): Not supplying enough data to HAL, expected position 307008 , only wrote 306720
    07-09 14:54:08.832: W/ActivityThread(14126): handleWindowVisibility: no activity for token android.os.BinderProxy@439547c
    07-09 14:54:08.860: D/gralloc_ranchu(1650): gralloc_alloc: Creating ashmem region of size 9334784
    07-09 14:54:08.919: D/monodroid-assembly(14126): typemap: MVID [E69730C8-3F3C-41A1-B2C9-CC70E17168E1] maps to assembly Xamarin.Forms.Platform.Android, looking for token 33554467 (0x2000023), table index 35
    07-09 14:54:08.919: D/monodroid-assembly(14126): typemap: type with token 33554467 (0x2000023) in module {E69730C8-3F3C-41A1-B2C9-CC70E17168E1} (Xamarin.Forms.Platform.Android) corresponds to Java type 'crc643f46942d9dd1fff9/FormsAppCompatActivity'
    07-09 14:54:08.919: I/monodroid-timing(14126): Typemap.managed_to_java: end, total time; elapsed: 0s:0::470665
    07-09 14:54:08.946: D/gralloc_ranchu(1650): gralloc_alloc: Creating ashmem region of size 9334784
    07-09 14:54:08.967: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.162: I/chatty(1640): uid=1041(audioserver) writer identical 13 lines
    07-09 14:54:09.176: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.182: E/mono(14126): Unhandled Exception:
    07-09 14:54:09.182: E/mono(14126): System.ArgumentNullException: Value cannot be null.
    07-09 14:54:09.182: E/mono(14126): Parameter name: key
    07-09 14:54:09.182: E/mono(14126):   at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <bd3bbca1bea44240800c6853da0ea670>:0 
    07-09 14:54:09.182: E/mono(14126):   at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <bd3bbca1bea44240800c6853da0ea670>:0 
    07-09 14:54:09.182: E/mono(14126):   at Java.Interop.TypeManager.RegisterType (System.String java_class, System.Type t) [0x0001c] in <4b06b8846e604735b7bb5ae66ad98f56>:0 
    07-09 14:54:09.182: E/mono(14126):   at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x0005d] in <4b06b8846e604735b7bb5ae66ad98f56>:0 
    07-09 14:54:09.192: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.194: E/mono-rt(14126): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
    07-09 14:54:09.194: E/mono-rt(14126): Parameter name: key
    07-09 14:54:09.194: E/mono-rt(14126):   at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <bd3bbca1bea44240800c6853da0ea670>:0 
    07-09 14:54:09.194: E/mono-rt(14126):   at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <bd3bbca1bea44240800c6853da0ea670>:0 
    07-09 14:54:09.194: E/mono-rt(14126):   at Java.Interop.TypeManager.RegisterType (System.String java_class, System.Type t) [0x0001c] in <4b06b8846e604735b7bb5ae66ad98f56>:0 
    07-09 14:54:09.194: E/mono-rt(14126):   at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x0005d] in <4b06b8846e604735b7bb5ae66ad98f56>:0 
    07-09 14:54:09.207: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.223: I/chatty(1640): uid=1041(audioserver) writer identical 1 line
    07-09 14:54:09.237: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.242: D/EGL_emulation(2073): eglMakeCurrent: 0xdd6052a0: ver 3 0 (tinfo 0xdd603410)
    07-09 14:54:09.253: W/audio_hw_generic(1640): Hardware backing HAL too slow, could only write 0 of 720 frames
    07-09 14:54:09.255: D/EGL_emulation(2073): eglMakeCurrent: 0xdd6052a0: ver 3 0 (tinfo 0xdd603410)
    07-09 14:54:09.256: I/GnssLocationProvider(1918): WakeLock acquired by sendMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@d906a81)
    07-09 14:54:09.256: I/GnssLocationProvider(1918): WakeLock released by handleMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@d906a81)
    07-09 14:54:09.261: D/EGL_emulation(2073): eglMakeCurrent: 0xdd6052a0: ver 3 0 (tinfo 0xdd603410)
    07-09 14:54:09.263: I/ActivityManager(1918): Process com.ostusa.app (pid 14126) has died: fore TOP 
    07-09 14:54:09.263: W/libprocessgroup(1918): kill(-14126, 9) failed: No such process
    
  6. jonathanpeppers commented on Jul 9, 2020

    @jonathanpeppers
    Member

    Thanks, @codympearson I can reproduce the bug above now.

    @grendello when I do a diff between an .apk and the .aab the only file I've found that differs is libxamarin-app.so:

    libxamarin-app.so.zip

    Can you tell if there is something odd in here? The .NET assemblies and classes.dex are identical.

  7. grendello commented on Jul 10, 2020

    @grendello
    Contributor

    @jonathanpeppers the libxamarin-app.so binaries are identical except for the different build id, which you noticed on Slack. The type maps are identical.

  8. jonathanpeppers commented on Jul 10, 2020

    @jonathanpeppers
    Member

    After more testing, we can reproduce this issue in a "hello world" app:

    https://github.com/xamarin/xamarin-android/tree/master/samples/HelloWorld

    If you add <application android:extractNativeLibs="false" to AndroidManifest.xml. App bundles happen to use this setting.

    It seems to only occur on an x86 Android 9.0 emulator, the x86_64 emulator works.

  9. 5 remaining items

  10. brendanzagaeski commented on Aug 26, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

    Fix included in Xamarin.Android SDK version 11.0.99.34.

    Fix included on Windows in Visual Studio 2019 version 16.8 Preview 2. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 2. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

  11. brendanzagaeski commented on Nov 10, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Release version of Xamarin.Android has now been published that includes the fix for this item.

    Fix included in Xamarin.Android SDK version 11.1.0.17.

    Fix included on Windows in Visual Studio 2019 version 16.8. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.8. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

  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

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions