Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio 3.0 error: style attribute '@android:attr/windowEnterAnimation' not found

I had followed steps of migrating to android studio 3.0 updgradation.

build.gradle

    flavorDimensions 'dimensionless'

D:\R\merchant\projapp\popuplibrary\build\intermediates\bundles\debug\res\values\values.xml Error:(28, 5) error: style attribute '@android:attr/windowEnterAnimation' not found.
C:\Users\user.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\f7bb6db2aa55d14683d1c9ddd8d49e03\res\values\values.xml Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':popuplibrary:processDebugAndroidTestResources'. Failed to execute aapt

Facing same issue but it is apccompat library also creating issue in my case.

style attribute '@android:attr/windowEnterAnimation' not found


gradlewrapper:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

build.gradle app:

   productFlavors {
                dev {
                    applicationIdSuffix '.dev'
                    versionName "1.0"
                    versionNameSuffix '-dev'
                    }
qa {
                    applicationIdSuffix '.qa'
                    versionName "1.0"
                    versionNameSuffix '-qa'
                    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    //Butter Knife
    compile 'com.jakewharton:butterknife:8.7.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'

    compile project(':popuplibrary')
}
like image 929
AskQ Avatar asked Oct 31 '17 10:10

AskQ


People also ask

How to resolve style attribute'ATTR/ATTR/my_ATTR'not found'error?

Error: style attribute 'attr/attr/my_attr (aka my.package:attr/attr/my_attr)' not found. To resolve this error, explicitly declare the type using type="attr": Additionally, when declaring a <style> element, its parent must also be style resource type. Otherwise, you get an error similar to the following:

How do I enable aapt2 in Android Studio?

Android Gradle Plugin 3.0.0 and higher enable AAPT2 by default, and you typically won't need to invoke aapt2 yourself. However, if you prefer to use your terminal and your own build system over Android Studio, you can use AAPT2 from the command line. You can also debug build errors related to AAPT2 from the command line.

How to disable aapt2 in Gradle?

If you are experiencing issues while using AAPT2, you can disable it by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line. Show activity on this post.

How to fix Android compilesdkversion and buildtoolsversion are not working?

Try to use the subprojects {} block in android/build.gradle and set the recent android compileSdkVersion and buildToolsVersion used in the main project so that the subprojects use these versions too. Show activity on this post. Add android.enableAapt2=false in the gradle.properties file fixes this issue.


2 Answers

This issue is described in the migration guide for Android Gradle Plugin 3.0.0.

Incorrect use of @ resource reference symbols

AAPT2 now throws build errors when you omit or incorrectly place resource reference symbols (@). For example, consider if you omit the symbol when specifying a style attribute, as shown below:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  ...
  <!-- Note the missing '@' symbol when specifying the resource type. -->
  <item name="colorPrimary">color/colorPrimary</item>
</style>

When building the module, AAPT2 now throws the following build error:

ERROR: expected color but got (raw string) color/colorPrimary

Additionally, consider if you incorrectly include the symbol when accessing a resource from the android namespace, as shown below:

...
<!-- When referencing resources from the 'android' namespace, omit the '@' symbol. -->
<item name="@android:windowEnterAnimation"/>

When building the module, AAPT2 now throws the following build error:

Error: style attribute '@android:attr/windowEnterAnimation' not found

If you didn't make the mistake described in second half, then perhaps an old version of appcompat-v7 is to blame.

The good

Update to newer support libraries, pick 25.4.0 or 26.1.0 or 27.0.0. Make sure you match compileSdkVersion.

Note: If you choose to update to something older than 27.0.0 you may run into this issue.

The bad

If for some reason you're stuck with 25.3.1 or older you can disable AAPT2.

If you are experiencing issues while using AAPT2, you can disable it by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

like image 113
Eugen Pechanec Avatar answered Sep 22 '22 11:09

Eugen Pechanec


Try to use the subprojects{} block in android/build.gradle and set the recent android compileSdkVersion and buildToolsVersion used in the main project so that the subprojects use these versions too.

Example

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion "27.0.3"
            }
        }
    } }
like image 36
Olivier Avatar answered Sep 19 '22 11:09

Olivier