Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2019 16.2 Preview3 - 9.4.0.34 - My app crashes on Startup on Android 4.4 #3314

Closed
michaldobrodenka opened this issue Jul 2, 2019 · 12 comments · Fixed by #3329
Closed

VS2019 16.2 Preview3 - 9.4.0.34 - My app crashes on Startup on Android 4.4 #3314

michaldobrodenka opened this issue Jul 2, 2019 · 12 comments · Fixed by #3329
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended.

Comments

@michaldobrodenka
Copy link

Steps to Reproduce

  1. Xamarin Android app with support libraries
  2. Deploy to Phone/Emulator with Android 4.4 on Release & AOT
  3. Crash

Since it seems related to resources, I've tried aapt1/2, Multidex On/Off (before this release Multidex was a must). My app has inherited Application class. On newer android emulators/phones app starts and runs without problems.

Expected Behavior

App start

Actual Behavior

Crash

Version Information

VS2019 16.2 Preview3 - Xamarin Android 9.4.0.34

Xamarin.Android Reference Assemblies and MSBuild support.
Mono: mono/mono@c6edaa62f94
Java.Interop: xamarin/java.interop/d16-2@b2b2610
LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@4f717b6

Log File

07-02 09:31:36.142 Samsung SM-G935F Info 7315 MonoDroid android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058
at android.content.res.Resources.loadDrawable(Resources.java:2096)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:360)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
07-02 09:31:36.142 Samsung SM-G935F Info 7315 MonoDroid Java.Lang.RuntimeException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058 ---> Org.XmlPull.V1.XmlPullParserException: Binary XML file line #15: invalid drawable tag vector
--- End of inner exception stack trace ---
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <8ec76afc5f8640c088245f6453eab7f7>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <8ec76afc5f8640c088245f6453eab7f7>:0
at Android.App.Activity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00031] in :0
at Com.TapHome.Android.SplashActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00000] in <712544763d22402c91a2d2637f069005>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in :0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.11(intptr,intptr,intptr)
--- End of managed Java.Lang.RuntimeException stack trace ---
07-02 09:31:36.142 Samsung SM-G935F Info 7315 MonoDroid UNHANDLED EXCEPTION:
07-02 09:31:36.138 Samsung SM-G935F Error 7315 VdcInflateDelegate org.xmlpull.v1.XmlPullParserException: Binary XML file line #15 tag requires viewportWidth > 0
at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:690)
at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:623)
at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:586)
at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:775)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:363)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)

@Abesoddy
Copy link

Abesoddy commented Jul 3, 2019

Same issue...

@jonathanpeppers jonathanpeppers self-assigned this Jul 5, 2019
@jonathanpeppers
Copy link
Member

@michaldobrodenka or @Abesoddy can you provide the full adb logcat output?

If it happened on your splash screen, can you make a small sample app I can try to see this?

@jonathanpeppers jonathanpeppers added this to the d16-3 milestone Jul 5, 2019
@jonathanpeppers jonathanpeppers added Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended. need-info Issues that need more information from the author. labels Jul 5, 2019
@jonathanpeppers
Copy link
Member

Ok, I was able to reproduce it with a new Xamarin.Forms Master/Detail template and a Android 4.4 / API 19 emulator.

It appears to be something related to aapt2, unchecking this box solved the issue for me:

image

It could also be related to this React Native issue where they are seeing the exact same error message/same API level: oblador/react-native-vector-icons#457

@jonathanpeppers jonathanpeppers removed the need-info Issues that need more information from the author. label Jul 5, 2019
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Jul 5, 2019
Fixes: dotnet#3314

Create a new Xamarin.Forms project using aapt2, you will encounter a
crash on startup for API 19 devices:

    android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058
    at android.content.res.Resources.loadDrawable(Resources.java:2096)
    at android.content.res.Resources.getDrawable(Resources.java:700)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:360)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
    at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
    at dalvik.system.NativeStart.main(Native Method)
    Java.Lang.RuntimeException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058 --->
    Org.XmlPull.V1.XmlPullParserException: Binary XML file line #15: invalid drawable tag vector

Reviewing the logs, there was a missing `--no-version-vectors` flag?

The Xamarin.Android.Support.Vector.Drawable NuGet was setting this
value:

    Target _XamarinAndroidSupportVectorDrawableArgs
        AndroidResgenExtraArgs = --no-version-vectors

Unfortunately the logic for passing this flag to aapt2 was happening
*too soon*, at this point `$(AndroidResgenExtraArgs)` is blank:

    <AndroidAapt2LinkExtraArgs Condition=" '$(_AndroidUseAapt2)' == 'True' And $(AndroidResgenExtraArgs.Contains('--no-version-vectors')) And !($(AndroidAapt2LinkExtraArgs.Contains('--no-version-vectors'))) ">--no-version-vectors $(AndroidAapt2LinkExtraArgs) </AndroidAapt2LinkExtraArgs>

The simple solution here is to move this property at the beginning of
`_UpdateAndroidResgen` and the problem is solved.

I added a test verifying that we are getting the
`--no-version-vectors` flag for both aapt and aapt2.
@cassionandi
Copy link

I had this problema even with debug mode. Yesterday I solved by uninstalling all "support" packages anda reinstalling.

@jonathanpeppers
Copy link
Member

If you are specifically getting:

android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058

Then the command-line invocation of aapt/aapt2 needs the --no-version-vectors switch.

To workaround you can either:

  • Disable aapt2 (aapt1 seems to work fine)
  • Set <AndroidAapt2LinkExtraArgs>--no-version-vectors</AndroidAapt2LinkExtraArgs> in your csproj

I don't how reinstalling NuGet packages would fix it, unless you removed the Xamarin.Android.Support.Vector.Drawable NuGet package.

@cassionandi
Copy link

the project don't have Xamarin.Android.Support.Vector.Drawable NuGet package.

@michaldobrodenka
Copy link
Author

Ok, I've created minimal test app. In fact, it is just new project from VS template. It doesn't start on Android 4.4. I tryied --no-version-vectors , aapt1/2, Release or Debug.

StartupTestApp.zip

@jonathanpeppers
Copy link
Member

@michaldobrodenka this is a different error than before:

07-09 10:25:41.492 I/MonoDroid( 4691): UNHANDLED EXCEPTION:
07-09 10:25:41.492 I/MonoDroid( 4691): Android.Content.Res.Resources+NotFoundException: File sans-serif from xml type layout resource ID #0x7f0a001a ---> Java.IO.FileNotFoundException: sans-serif
07-09 10:25:41.492 I/MonoDroid( 4691):    --- End of inner exception stack trace ---
07-09 10:25:41.492 I/MonoDroid( 4691):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0 
07-09 10:25:41.492 I/MonoDroid( 4691):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0 
07-09 10:25:41.492 I/MonoDroid( 4691):   at Android.App.Activity.SetContentView (System.Int32 layoutResID) [0x00022] in <a3756e1288ad4852a2bdd7e089780695>:0 
07-09 10:25:41.492 I/MonoDroid( 4691):   at StartupTestApp.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00011] in C:\Users\jopepper\Downloads\StartupTestApp\StartupTestApp\MainActivity.cs:21 
07-09 10:25:41.492 I/MonoDroid( 4691):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <a3756e1288ad4852a2bdd7e089780695>:0 
07-09 10:25:41.492 I/MonoDroid( 4691):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.4(intptr,intptr,intptr)
07-09 10:25:41.492 I/MonoDroid( 4691):   --- End of managed Android.Content.Res.Resources+NotFoundException stack trace ---
07-09 10:25:41.492 I/MonoDroid( 4691): android.content.res.Resources$NotFoundException: File sans-serif from xml type layout resource ID #0x7f0a001a
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.Resources.loadXmlResourceParser(Resources.java:2361)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.Resources.loadXmlResourceParser(Resources.java:2316)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.Resources.getLayout(Resources.java:939)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at md58f6e2e68b2ef5e7866eaae557a38b45c.MainActivity.n_onCreate(Native Method)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at md58f6e2e68b2ef5e7866eaae557a38b45c.MainActivity.onCreate(MainActivity.java:35)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.Activity.performCreate(Activity.java:5231)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.os.Looper.loop(Looper.java:136)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at java.lang.reflect.Method.invoke(Method.java:515)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at dalvik.system.NativeStart.main(Native Method)In mgmain JNI_OnLoad

07-09 10:25:41.492 I/MonoDroid( 4691): Caused by: java.io.FileNotFoundException: sans-serif
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.AssetManager.openXmlAssetNative(Native Method)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:488)
07-09 10:25:41.492 I/MonoDroid( 4691): 	at android.content.res.Resources.loadXmlResourceParser(Resources.java:2343)
07-09 10:25:41.492 I/MonoDroid( 4691): 	... 22 more

This project fails for me on any device/emulator. Is it just an issue with this font?

jonathanpeppers added a commit that referenced this issue Jul 9, 2019
…3329)

Fixes: #3314

Create a new Xamarin.Forms project using aapt2, you will encounter a
crash on startup for API 19 devices:

    android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058
    at android.content.res.Resources.loadDrawable(Resources.java:2096)
    at android.content.res.Resources.getDrawable(Resources.java:700)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:360)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
    at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
    at dalvik.system.NativeStart.main(Native Method)
    Java.Lang.RuntimeException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058 --->
    Org.XmlPull.V1.XmlPullParserException: Binary XML file line #15: invalid drawable tag vector

Reviewing the logs, there was a missing `--no-version-vectors` flag?

The Xamarin.Android.Support.Vector.Drawable NuGet was setting this
value:

    Target _XamarinAndroidSupportVectorDrawableArgs
        AndroidResgenExtraArgs = --no-version-vectors

Unfortunately the logic for passing this flag to aapt2 was happening
*too soon*, at this point `$(AndroidResgenExtraArgs)` is blank:

    <AndroidAapt2LinkExtraArgs Condition=" '$(_AndroidUseAapt2)' == 'True' And $(AndroidResgenExtraArgs.Contains('--no-version-vectors')) And !($(AndroidAapt2LinkExtraArgs.Contains('--no-version-vectors'))) ">--no-version-vectors $(AndroidAapt2LinkExtraArgs) </AndroidAapt2LinkExtraArgs>

The simple solution here is to move this property at the beginning of
`_UpdateAndroidResgen` and the problem is solved.

I added a test verifying that we are getting the
`--no-version-vectors` flag for both aapt and aapt2.
jonpryor pushed a commit that referenced this issue Jul 22, 2019
…3329)

Fixes: #3314

Create a new Xamarin.Forms project using aapt2, you will encounter a
crash on startup for API 19 devices:

    android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058
    at android.content.res.Resources.loadDrawable(Resources.java:2096)
    at android.content.res.Resources.getDrawable(Resources.java:700)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:360)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
    at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
    at dalvik.system.NativeStart.main(Native Method)
    Java.Lang.RuntimeException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058 --->
    Org.XmlPull.V1.XmlPullParserException: Binary XML file line #15: invalid drawable tag vector

Reviewing the logs, there was a missing `--no-version-vectors` flag?

The Xamarin.Android.Support.Vector.Drawable NuGet was setting this
value:

    Target _XamarinAndroidSupportVectorDrawableArgs
        AndroidResgenExtraArgs = --no-version-vectors

Unfortunately the logic for passing this flag to aapt2 was happening
*too soon*, at this point `$(AndroidResgenExtraArgs)` is blank:

    <AndroidAapt2LinkExtraArgs Condition=" '$(_AndroidUseAapt2)' == 'True' And $(AndroidResgenExtraArgs.Contains('--no-version-vectors')) And !($(AndroidAapt2LinkExtraArgs.Contains('--no-version-vectors'))) ">--no-version-vectors $(AndroidAapt2LinkExtraArgs) </AndroidAapt2LinkExtraArgs>

The simple solution here is to move this property at the beginning of
`_UpdateAndroidResgen` and the problem is solved.

I added a test verifying that we are getting the
`--no-version-vectors` flag for both aapt and aapt2.
jonpryor pushed a commit that referenced this issue Jul 22, 2019
…3329)

Fixes: #3314

Create a new Xamarin.Forms project using aapt2, you will encounter a
crash on startup for API 19 devices:

    android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058
    at android.content.res.Resources.loadDrawable(Resources.java:2096)
    at android.content.res.Resources.getDrawable(Resources.java:700)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:360)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at com.taphome.offline.SplashActivity.n_onCreate(Native Method)
    at com.taphome.offline.SplashActivity.onCreate(SplashActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
    at dalvik.system.NativeStart.main(Native Method)
    Java.Lang.RuntimeException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f080058 --->
    Org.XmlPull.V1.XmlPullParserException: Binary XML file line #15: invalid drawable tag vector

Reviewing the logs, there was a missing `--no-version-vectors` flag?

The Xamarin.Android.Support.Vector.Drawable NuGet was setting this
value:

    Target _XamarinAndroidSupportVectorDrawableArgs
        AndroidResgenExtraArgs = --no-version-vectors

Unfortunately the logic for passing this flag to aapt2 was happening
*too soon*, at this point `$(AndroidResgenExtraArgs)` is blank:

    <AndroidAapt2LinkExtraArgs Condition=" '$(_AndroidUseAapt2)' == 'True' And $(AndroidResgenExtraArgs.Contains('--no-version-vectors')) And !($(AndroidAapt2LinkExtraArgs.Contains('--no-version-vectors'))) ">--no-version-vectors $(AndroidAapt2LinkExtraArgs) </AndroidAapt2LinkExtraArgs>

The simple solution here is to move this property at the beginning of
`_UpdateAndroidResgen` and the problem is solved.

I added a test verifying that we are getting the
`--no-version-vectors` flag for both aapt and aapt2.
@brendanzagaeski
Copy link
Contributor

Release status update

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

Fix included in Xamarin.Android 10.0.0.43

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

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

@alexshikov
Copy link

Just run into this issue on Samsung with Android 4.4 device

Using:

  • Visual Studio Community 2019 for Mac: Version 8.4.4 (build 91)
  • Xamarin.Android: Version: 10.1.3.7 (Visual Studio Community)
  • Xamarin.Forms: 4.3.0.947036
  • AAPT2 enabled

Adding <AndroidAapt2LinkExtraArgs>--no-version-vectors</AndroidAapt2LinkExtraArgs>to the .csproj seems to fixed the issue.

@jonathanpeppers
Copy link
Member

@alexshikov can you file a new issue, including a diagnostic MSBuild log? Thanks!

@SamihElsakhawi
Copy link

Just run into this issue on Samsung with Android 4.4 device

Using:

  • Visual Studio Community 2019 for Mac: Version 8.4.4 (build 91)
  • Xamarin.Android: Version: 10.1.3.7 (Visual Studio Community)
  • Xamarin.Forms: 4.3.0.947036
  • AAPT2 enabled

Adding <AndroidAapt2LinkExtraArgs>--no-version-vectors</AndroidAapt2LinkExtraArgs>to the .csproj seems to fixed the issue.

I had the same issue, and adding <AndroidAapt2LinkExtraArgs>--no-version-vectors</AndroidAapt2LinkExtraArgs>to the .csproj fixed my issue.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants