Invalid resource value allowed for an application compiled with Android Studio 3.0

We are faced with an incomprehensible problem, since we upgraded to Android Studio 3.0 (with Android Gradle plugin 3.0.0).

Our application uses the MaterialEditText library . Prior to AS 3.0, everything worked fine. Now, after we migrated the project to AS 3.0 and compiled the application with this version of Android Studio and the Gradle plugin associated with it, the application will be disabled when using the MaterialEditText components:

Caused by: java.lang.RuntimeException: Font asset not found res/drawable-mdpi-v4/ic_clear_search_api_holo_dark.png
   at android.graphics.Typeface.createFromAsset(Typeface.java:304)
   at com.rengwuxian.materialedittext.MaterialAutoCompleteTextView.getCustomTypeface(MaterialAutoCompleteTextView.java:488)
   at com.rengwuxian.materialedittext.MaterialAutoCompleteTextView.init(MaterialAutoCompleteTextView.java:385)
   at com.rengwuxian.materialedittext.MaterialAutoCompleteTextView.<init>(MaterialAutoCompleteTextView.java:325)
     ... 40 more

It seems that it typedArray.getString(R.styleable.MaterialEditText_met_accentTypeface)suddenly resolves some random path that can be traced on line MaterialAutoCompleteTextView 383 . However, this only happens on devices with Android below 8.0 . On Android 8.0, the application works fine.

Our styles were not changed during the upgrade to AS 3.0:

<item name="met_typeface">fonts/UnitRoundedOT.otf</item>
<item name="met_accentTypeface">fonts/UnitRoundedOT.otf</item>

Also see the related issue in the MaterialEditText library.

When porting an Android project to AS 3.0, it seems like only using the new Gradle plugin

classpath 'com.android.tools.build:gradle:3.0.0'

Without changing the rest of the Gradle files, it is enough to provoke this error. However, a fully migrated project also has this problem.

Could this be a Gradle plugin error?

+4
source share
1

-, ,

strings.xml:

<string name="font_unit_rounded">fonts/UnitRoundedOT.otf</string>

styles.xml:

<item name="met_typeface">@string/font_unit_rounded</item>
<item name="met_accentTypeface">@string/font_unit_rounded</item>

. 346. - , Android Studio 3.0 Android < 8,0. , , Android Gradle.

0

Source: https://habr.com/ru/post/1688594/


All Articles