Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Support Library Build v26.X.X Build Error: Attribute "font" already defined

I'm trying to upgrade from version 25.3.1 to version 26.X.X of the support library, but every time I build the project using the newer version I get this error:

Error:(357) Attribute "font" already defined with incompatible format.
Error:(343) Original attribute defined here.

Error:java.util.concurrent.ExecutionException: 
com.android.ide.common.process.ProcessException: Error while executing 
process /Users/johnsmith/Library/Android/sdk/build-tools/26.0.1/aapt 
with arguments {package -f --no-crunch -I ...

I have tried cleaning and rebuilding. I have also tried invalidating caches and restarting Android Studio.

The app builds fine with version 25.3.1 of the support library. I'm using Android Studio 3.0 Beta 2 with version 3.0.0-beta2 of the Android Gradle plugin.

like image 804
mco Avatar asked Aug 12 '17 03:08

mco


2 Answers

Since this error is:

  • Android O specific,
  • related to a font attribute, and
  • an error thrown by aapt,

my guess is that you have defined a custom attribute named font in your application code that conflicts in some manner with the android-namespaced font attribute introduced in Android O. Try renaming or removing that custom attribute.

like image 67
stkent Avatar answered Nov 05 '22 04:11

stkent


you should change the "font" attribute name that used in customView

<declare-styleable name="AATextView">
    <attr name="font" format="string"/>
</declare-styleable>

for example :

<declare-styleable name="AATextView">
    <attr name="typeface" format="string"/>
</declare-styleable>
like image 40
Shahab Saalami Avatar answered Nov 05 '22 04:11

Shahab Saalami