安卓工作室 3.0 错误 : style attribute '@android:attr/windowEnterAnimation' not found

标签 android android-studio-3.0

我已经按照迁移到 android studio 3.0 updgradation 的步骤进行操作。

构建.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

面临同样的问题,但 apccompat 库也在我的案例中造成了问题。

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


渐变包装器:

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 应用程序:

   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')
}

最佳答案

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

如果您没有犯下半部分所述的错误,那么旧版本的 appcompat-v7 可能是罪魁祸首。

好的

更新到较新的支持库,选择 25.4.0 或 26.1.0 或 27.0.0。确保匹配 compileSdkVersion

注意:如果您选择更新到 27.0.0 之前的版本,您可能会遇到 this issue .

不好

如果出于某种原因您无法使用 25.3.1 或更早版本,您可以 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.

关于安卓工作室 3.0 错误 : style attribute '@android:attr/windowEnterAnimation' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47033594/

相关文章:

java - 线性布局对于空 View 的行为如何?

javascript - Firebase Firestore - 在 Stripe.CreateCustomer 之后通过 Cloud Function 更新 Firestore 数据库

java - 错误 : Duplicate zip entry [43. jar :org/apache/http/annotation/NotThreadSafe. 类]

Android Studio 3 和 Gradle 4.3 -> 库模块不再处理本地 JAR -> 如何处理?

java - Android - 使用 'instanceof' 是确定从 "onItemSelected"中的 Spinner 返回的项目类型的唯一方法吗?

android - RecyclerView Adapter 中的静态和非静态 View 有什么区别?

android - 重复位图在 View 的 state_pressed 上渲染不佳

android - 不推荐使用 RegisterResGeneratingTask,使用 registerGeneratedFolders(FileCollection)

android-studio-3.0 - 在android studio 3.0中搜索库依赖

android - 我正在使用 Ubuntu 17.04,当我尝试安装 android studio 并运行我的虚拟设备时,它会出现这些错误