【问题标题】:android studio 3.0 error: style attribute '@android:attr/windowEnterAnimation' not foundandroid studio 3.0 错误:找不到样式属性“@android:attr/windowEnterAnimation”
【发布时间】:2018-04-12 12:22:17
【问题描述】:

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

build.gradle

    flavorDimensions 'dimensionless'

D:\R\merchant\projapp\popuplibrary\build\intermediates\bundles\debug\res\values\values.xml 错误:(28, 5) 错误:未找到样式属性“@android:attr/windowEnterAnimation”。
C:\Users\user.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\f7bb6db2aa55d14683d1c9ddd8d49e03\res\values\values.xml 错误:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息
错误:任务 ':popuplibrary:processDebugAndroidTestResources' 执行失败。 aapt 执行失败

面临同样的问题,但在我的情况下,apccompat 库也造成了问题。

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

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

【问题讨论】:

  • 你能提供你的 gradle.properties , gradle.app 吗?
  • 有问题更新
  • 谢谢,还有 build.gradle (app) 让我检查你的依赖项和你的实现。

标签: android android-studio-3.0


【解决方案1】:

migration guide for Android Gradle Plugin 3.0.0 中描述了此问题。

@资源引用符号的错误使用

现在,当您省略或错误放置资源引用符号 (@) 时,AAPT2 会引发构建错误。例如,考虑在指定样式属性时是否省略符号,如下所示:

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

在构建模块时,AAPT2 现在会抛出以下构建错误:

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

另外,请考虑在从android命名空间访问资源时是否错误地包含符号,如下所示:

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

在构建模块时,AAPT2 现在会抛出以下构建错误:

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

如果您在使用 AAPT2 时遇到问题,可以通过在您的 gradle.properties 文件中设置 android.enableAapt2=false 来禁用它,并通过从命令行运行 ./gradlew --stop 来重新启动 Gradle 守护程序。

【讨论】:

  • gradle.properties 或 gradle.wrapper.properties
【解决方案2】:

尝试使用 android/build.gradle 中的 subprojects{} 块,并设置主项目中使用的最近的 android compileSdkVersion 和 buildToolsVersion,以便子项目也使用这些版本。

例子

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion "27.0.3"
            }
        }
    } }

【讨论】:

    【解决方案3】:

    gradle.properties 文件中添加android.enableAapt2=false 可解决此问题。

    【讨论】:

    • 警告:以下项目选项已弃用并已删除:android.enableAapt2 此属性无效,现在始终使用 AAPT2。
    【解决方案4】:

    就我而言,我在 build.gradle 中删除/更新了 thebuildToolsVersion "27.0.3"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 2022-07-02
      • 2017-10-28
      • 1970-01-01
      相关资源
      最近更新 更多