好的,我在 Android Studio 3.0 中创建了一个全新的项目。 Gradle build 在这个新实例化的项目中运行良好,直到我在模块的 build.gradle
dependencies {
...
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.1.0'
}
这是我在构建日志中遇到的错误
/home/sparker0i/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.0.1.aar/e06e09188fb79d4d895b39247477d1c1/res/values/values.xml
Error:(246, 5) resource android:attr/foregroundInsidePadding is private
当我双击它时,我得到一个 values.xml 文件(合并的一个),其中指针位于
<dimen name="abc_action_bar_content_inset_material">16dp</dimen>
我的最低 SDK 版本是 16,目标 SDK 是 26。我使用的是 Android Studio 3.0 Beta 2,构建工具版本是 26.0.1。 Gradle 插件 3.0.0-beta2.
我敢打赌这是因为 Cardslib 库稍微过时了。有没有办法解决这个问题? (从依赖项中删除这些行可以正常工作)
最佳答案
尝试禁用 AAPT2通过添加 android.enableAapt2=false给您的gradle.properties文件。
Builds may fail while AAPT2 is enabled. Additionally, AAPT2 is currently not compatible with Robelectric. If your build fails due to an AAPT2 resource processing issue or you want to use Roboelectric, you can disable AAPT2 by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.
引用:here
我使用的是 Android Studio 3.0 beta 5,其中我禁用了 AAPT2它解决了我的错误。
更新日期:2018 年 3 月 28 日
使用 Android Studio 3.1.1这可能行不通。您的图书馆之一可能正在使用 android 的私有(private)资源。您需要找到导致库的错误并替换android:attr/foregroundInsidePadding与 foregroundInsidePadding并将其导入您的项目。
xml有
<attr name="android:foregroundInsidePadding" />并将其替换为<attr name="foregroundInsidePadding" />和构建。build.gradle . AAPT2所以尝试改变android.enableAapt2=false至true在 gradle.properties如果存在。关于android - Cardslib错误资源android :attr/foregroundInsidePadding is private while targeting SDK 26,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45865366/