Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by smdevidan · Oct 05, 2016 at 05:27 AM · androidcrashandroid buildandroid-sdk

Unity Android build support for support v7 v24.x.x

I have been trying to update my plugin to use support libs v24.x.x I use appcompat support v7 library in my plugin and facing a runtime crash whenever I start an activity that extends AppCompatActivity :

Following is the crash trace : 09-28 15:23:55.721 16455-16455/com.example.qotdapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.qotdapp, PID: 16455 java.lang.RuntimeException: Unable to start activity ComponentInfo {com.example.qotdapp/com.example.qotdapp.MainActivity} : android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access$900(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) 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:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f at android.content.res.Resources.loadDrawable(Resources.java:3422) at android.content.res.Resources.getDrawable(Resources.java:1909) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182) at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187) at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:127) at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:147) at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:27) at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:50) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181) at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) at com.example.qotdapp.MainActivity.onCreate(MainActivity.java:102) at android.app.Activity.performCreate(Activity.java:5451) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access$900(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) 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:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:986) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) at android.content.res.Resources.loadDrawable(Resources.java:3418) at android.content.res.Resources.getDrawable(Resources.java:1909) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182) at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187) at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:127) at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:147) at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:27) at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:50) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181) at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) at com.example.qotdapp.MainActivity.onCreate(MainActivity.java:102) at android.app.Activity.performCreate(Activity.java:5451) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access$900(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) 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:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method)

Android suggested a fix via gradlle upgrade to 2.2 or adding a flag in the gradle script here : http://stackoverflow.com/questions/35739743/file-res-drawable-abc-ic-ab-back-material-xml-from-drawable-resource-id-0x7f020/35740506#35740506

The new gradle update by default adds the "--no-version-vector" flag when running the aapt command and that resolves the issue. But Unity android build command does not add this flag, hence using appcompat lib 24.x.x always crashes. The issue does not occur when using appcompat 23.4.0.

Is there a way to add this flag to the aapt command executed by Unity build process? Or any other way i can fix this crash?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by liortal · Oct 05, 2016 at 06:11 AM

Is there a way to add this flag to the aapt command executed by Unity build process? Or any other way i can fix this crash?

No, Unity is "hard wired" to use a specific set of arguments to the build tools.

In latest 5.5 beta, you can build your Unity project into a Gradle project that can be further customized and only then built using Gradle. Not sure whether this is a viable option for you.

The issue that is causing the crash is this:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.qotdapp, PID: 16455 java.lang.RuntimeException: Unable to start activity ComponentInfo {com.example.qotdapp/com.example.qotdapp.MainActivity} : android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f

You are missing some drawable resource (abc_vector_test). Check if your libraries + build tools all have compatible versions (e.g: build tools 24.x with support lib 24.x, etc)

EDIT: According to this link this is an "expected" issue, which should be solved either by adding an extra parameter to the gradle build file, or an argument to AAPT.

The article also mentions a "magic" way, you can try that by adding the following code to your activity code:

 static {
     AppCompatDelegate.setCompatVectorFromSourcesEnabled(true);
 }

You can give that a try to see if that works for you.

Other, hacky & crazier suggestions:

  1. Export a "Google android" project and then import that into Android studio and add whatever flags you need.

  2. Since the AAPT parameters are "hard coded", you could create a dummy aapt file that will act as a proxy between Unity and the real aapt file. Its only job will be to add the --no-version-vectors args (on top of the args passed by Unity). This will "simulate" a scenario where Unity actually adds this argument itself.

  3. Use the latest beta with gradle support :) and hope it just works.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image smdevidan · Oct 05, 2016 at 07:15 AM 0
Share

Thanks for a quick response.

I do have the file as a resource in the generated apk. I decompiled the apk and checked for all the indications for the error but didnt find any. The aapt build command actually affects whether this abc_vector_test gets added as a resource or not.

I double checked the build-tools, platform-tools versions , it points to 24.x version. Is there any other way to make it work? Are there reported issues for Android Nougat support on Unity? I didnt find any yet hence the question.

Would really appreciate all the help.

avatar image liortal smdevidan · Oct 05, 2016 at 05:36 PM 0
Share

please see my updated answer.

avatar image smdevidan liortal · Oct 06, 2016 at 08:03 AM 0
Share

I tried the code change :

 static {
      AppCompatDelegate.setCompatVectorFromSourcesEnabled(true);
  }
 
 

Does not seem to work. I think exporting to gradle project would be the way but currently i had to switch back to 23.4.0 support libs.

Hope Unity fixes this in android builds since many developers are going to start integrating with appcompat support libs 24.x

Thanks for the help!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

can not select android root folder 1 Answer

Android build failes because of manifest 0 Answers

Unity tries wrong Android "run device" 1 Answer

Debug apk is working but Signed apk apk is not working after inetgrating unity module into Android app 0 Answers

Cannot install apk in android 8.0.0 (API level 26) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges