android studio 3.0错误:未找到样式属性'@android:attr/windowEnterAnimation'

Ask*_*skQ 14 android android-studio-3.0

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

的build.gradle

    flavorDimensions 'dimensionless'
Run Code Online (Sandbox Code Playgroud)

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库也在我的案例中创建问题.

找不到样式属性'@android:attr/windowEnterAnimation'


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
Run Code Online (Sandbox Code Playgroud)

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')
}
Run Code Online (Sandbox Code Playgroud)

Eug*_*nec 28

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>
Run Code Online (Sandbox Code Playgroud)

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

ERROR: expected color but got (raw string) color/colorPrimary
Run Code Online (Sandbox Code Playgroud)

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

...
<!-- When referencing resources from the 'android' namespace, omit the '@' symbol. -->
<item name="@android:windowEnterAnimation"/>
Run Code Online (Sandbox Code Playgroud)

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

Error: style attribute '@android:attr/windowEnterAnimation' not found
Run Code Online (Sandbox Code Playgroud)

如果你没有犯下半部分描述的错误,那么也许应该归咎于appcompat-v7的旧版本.

好的

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

注意:如果您选择更新到早于27.0.0的内容,则可能会遇到此问题.

坏的

如果由于某种原因你被困在25.3.1或更早,你可以禁用AAPT2.

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