Description
When running our project with Xamarin.Android 9.3.0.23, the app crashes with a Android.Content.Res.Resources+NotFoundException
as soon as we try to use a resource that is bundled by an external library.
At first, I though this was caused by the library itself that was not correctly bundled, but then realized that it failed with any external library. This happens for example with Acr.UserDialogs or Plugin.Fingerprint.
Steps to Reproduce
Unfortunately, I do not have a working (crashing) example. I tried to make a repro project, but it works as expected.
Expected Behavior
Xamarin.Forms app can use resources from external libraries.
Actual Behavior
Android.Content.Res.Resources+NotFoundException: Resource ID #0x7f03005a
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
at Android.Views.LayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x0005a] in <ff9f3f3d4e134974a889db1b532c9b6e>:0
at MvvmCross.Platforms.Android.Binding.Views.MvxLayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x0003e] in C:\projects\mvvmcross\MvvmCross\Platforms\Android\Binding\Views\MvxLayoutInflater.cs:141
at Android.Views.LayoutInflater.n_Inflate_ILandroid_view_ViewGroup_Z (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 resource, System.IntPtr native_root, System.Boolean attachToRoot) [0x00011] in <ff9f3f3d4e134974a889db1b532c9b6e>:0
at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,int,intptr,bool)
at android.content.res.Resources$NotFoundException: Resource ID #0x7f03005a
at at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
at at android.content.res.Resources.loadXmlResourceParser(Resources.java:2155)
at at android.content.res.Resources.getLayout(Resources.java:1155)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at at mvvmcross.platforms.android.binding.views.MvxLayoutInflater.n_inflate(Native Method)
at at mvvmcross.platforms.android.binding.views.MvxLayoutInflater.inflate(MvxLayoutInflater.java:50)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at at android.support.v7.app.AlertDialog_IDialogInterfaceOnClickListenerImplementor.n_onClick(Native Method)
at at android.support.v7.app.AlertDialog_IDialogInterfaceOnClickListenerImplementor.onClick(AlertDialog_IDialogInterfaceOnClickListenerImplementor.java:30)
at at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at at android.os.Handler.dispatchMessage(Handler.java:106)
at at android.os.Looper.loop(Looper.java:193)
at at android.app.ActivityThread.main(ActivityThread.java:6718)
at at java.lang.reflect.Method.invoke(Native Method)
at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Version Information
From Visual Studio for Mac
=== Visual Studio Community 2019 for Mac ===Version 8.1.5 (build 9)
Installation UUID: c647d718-5745-4cd4-a94d-56ba562963eb
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.6.0.25 (d16-0 / 50f75273)
Package version: 518010028
=== Mono Framework MDK ===
Runtime:
Mono 5.18.1.28 (2018-08/223ea7ef92e) (64-bit)
Package version: 518010028
=== NuGet ===
Version: 5.0.2.5988
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.2.5
2.1.8
2.1.2
2.0.5
2.0.0
SDK: /usr/local/share/dotnet/sdk/2.2.300/Sdks
SDK Versions:
2.2.300
2.2.107
2.1.504
2.1.302
2.1.4
2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/msbuild/Current/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.10
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Xamarin.Android ===
Version: 9.3.0.23 (Visual Studio Community)
Commit: HEAD/d0b48056f
Android SDK: /Users/jonas/Library/Android/sdk
Supported Android versions:
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
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.1
SDK Build Tools Version: 29.0.0 rc1
Build Information:
Mono: mono/mono@3a07bd426d3
Java.Interop: xamarin/java.interop/d16-1@5ddc3e3
LibZipSharp: grendello/LibZipSharp/d16-1@44de300
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/jonas/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 Device Manager ===
Version: 1.2.0.44
Hash: aac645b
Branch: remotes/origin/d16-1
Build date: 2019-05-29 19:55:24 UTC
=== Xamarin Designer ===
Version: 16.1.0.467
Hash: f1657e133
Branch: remotes/origin/d16-1-new-document-model
Build date: 2019-06-18 21:57:42 UTC
=== Apple Developer Tools ===
Xcode 10.2 (14490.120)
Build 10E125
=== Xamarin.Mac ===
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.
=== Xamarin.iOS ===
Version: 12.10.0.157 (Visual Studio Community)
Hash: 6bd94753
Branch: d16-1
Build date: 2019-06-12 17:28:47-0400
=== 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: 801050009
Git revision: bd0ab28ba941b19b39322247db020dcd0fb305d0
Build date: 2019-07-03 17:15:21+00
Build branch: release-8.1
Xamarin extensions: 8cc25b5cb090e6c23b62a7901000c299977eb08d
=== Operating System ===
Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
Thu Apr 25 23:16:27 PDT 2019
root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
We are otherwise using Xamarin.Forms 4.0 and MvvmCross 6.2.3.
When using Xamarin.Android 9.1.8 it works fine. It started crashing with Xamarin.Android 9.2, and also 9.3 now. (I could not try with 9.4 preview because it does not compile, see #3343)
I am testing with Android 9, so it does not seem related to #3314.
Workarounds ?
I tried to disable AAPT2 like explained in the release notes. It does not help.
For now we can compile with Xamarin 9.1 and it works, but it does not look good for the future.