cardslib错误资源android:attr/foregroundInsidePadding在定位SDK 26时是私有的 [英] cardslib error resource android:attr/foregroundInsidePadding is private while targeting SDK 26

查看:232
本文介绍了cardslib错误资源android:attr/foregroundInsidePadding在定位SDK 26时是私有的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我已经在Android Studio 3.0中创建了一个全新的项目.在新实例化的项目中,Gradle构建工作正常,直到在模块的build.gradle

Okay, I have created a completely new project in Android Studio 3.0. Gradle build works fine in this newly instantiated project, until I insert the following lines in my module's 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'
}

这是我在构建日志中遇到的错误

Here is the error I get in the Build log

/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文件(合并的一个),其指针位于

When I double click on it, I get a values.xml file (merged one), where the pointer is at

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

My minimum SDK version is 16, target SDK is 26. I am using Android Studio 3.0 Beta 2, build tools version is 26.0.1. Gradle plugin 3.0.0-beta2.

我敢打赌,这是因为Cardslib库有些过时了.有没有办法解决这个问题? (从依赖项中删除这些行就可以了)

I bet this is because of a slightly outdated Cardslib library. Is there no way to fix this? (Removing those lines from dependencies works fine)

推荐答案

尝试通过在gradle.properties文件中添加android.enableAapt2=false来禁用AAPT2.

Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.

启用AAPT2时,构建可能会失败.此外,AAPT2是 目前与Robelectric不兼容.如果您的构建由于以下原因而失败 AAPT2资源处理问题,或者您想使用Roboelectric, 您可以通过将android.enableAapt2 = false设置为 gradle.properties文件并通过运行来重新启动Gradle守护程序 ./gradlew-从命令行停止.

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.

参考文献:此处

我使用的是Android Studio 3.0 beta 5,在其中我禁用了AAPT2并解决了我的错误.

I was using Android studio 3.0 beta 5 In which I disabled the AAPT2 and it resolved my error.

更新:2018年3月28日

对于Android Studio 3.1.1,这可能不起作用.您的图书馆之一可能正在使用android的私有资源.您需要找到导致库的错误,并用foregroundInsidePadding替换android:attr/foregroundInsidePadding并将其导入到您的项目中.

With Android Studio 3.1.1 this might not work. One of your library might be using android's private resource. You need to find the error causing library and replace android:attr/foregroundInsidePadding with foregroundInsidePadding and import it to your project.

  1. 在您本地的库中复制库.
  2. 在Android Studio中打开存储库,找到xml具有 <attr name="android:foregroundInsidePadding" />并替换为
    <attr name="foregroundInsidePadding" />和构建.
  3. 打开您的项目并将该存储库作为依赖项导入到您的项目中.
  4. 从应用程序级别build.gradle中删除库编译语句.
  5. 现在您可能可以使用AAPT2,因此请尝试将gradle.properties中的android.enableAapt2=false更改为true(如果存在).
  1. Clone the library repo in your local.
  2. Open repository in Android Studio find xml having <attr name="android:foregroundInsidePadding" /> and replace it with
    <attr name="foregroundInsidePadding" /> and Build.
  3. Open your project and import that repository as dependency into your project.
  4. Remove library compile statements from app level build.gradle.
  5. Now you might be able to use AAPT2 so try changing android.enableAapt2=false to true in gradle.properties if present.

这篇关于cardslib错误资源android:attr/foregroundInsidePadding在定位SDK 26时是私有的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆