Android Studio 3.0 issue


#1

I just upgraded to Android Studio 3.0 mid-way through chapter 13, after completing listing 13.7. Now I get a build error related to fragment_crime_list.xml:

Error:error: attribute 'res-auto:showAsAction' not found.
Error:attribute 'res-auto:showAsAction' not found.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt

This is the relevant code:
<?xml version="1.0" encoding="utf-8"?>

    <item
        android:id="@+id/new_crime"
        android:icon="@drawable/ic_menu_add"
        android:title="@string/new_crime"
        app:showAsAction="ifRoom|withText"
        />
</menu>

I found a bunch of suggested fixes on S.O. but nothing that really solves or explains why this is happening. Any ideas?


#2

I think, this line is your problem.

failed linking file resources.

AAPT (Android Asset Packaging Tool ) can compile resources. I think you should look at this.
I assume that your gradle is version 3.0.0. You can try,

android.enableAapt2=false in your gradle.properties file and restarting the Gradle.

I’m using android studio 3.0. But I don’t use the above code.Because I didn’t encounter this the problem.
Or you can check newly released.
And check this and this.


Android Studio 3.0
#3

I tried setting enableAapt2 to false, and it still had errors.

Then I looked back at the code and realized I had made a mistake in the XML. What I typed:
xmlns:app="http://schemas.android.com/apk/res/res-auto"

And the correct way:
xmlns:app="http://schemas.android.com/apk/res-auto"

Thanks for the response :slight_smile:


#4

Thanks a lottttttttttttttttttttttttttttttttttt…
Saved my hours…
it’s work for me…
it’s correct answer of aapt error…