android sdk 2.9.5.0,如何找到问题Android SDK 3.0错误:(9,5)错误:资源android:attr/colorError未找到...

当我做一个make时如何找到此错误的问题我收到此错误消息:

错误:(9,5)错误:找不到资源android:attr / colorError

奇怪的是我有2个build.gradle文件:

这里是我的build.gradle(Project:Projectname)文件:

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:3.0.0'

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

allprojects {

repositories {

jcenter()

maven {

url "https://maven.google.com"

}

}

}

task clean(type: Delete) {

delete rootProject.buildDir

}

这是我的build.gradle(模块:app)文件:

apply plugin: 'com.android.application'

android {

compileSdkVersion 22

defaultConfig {

applicationId "org.acme.nfcedit"

minSdkVersion 22

targetSdkVersion 26

versionCode 1

versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

productFlavors {

}

}

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation 'com.android.support:appcompat-v7:26.1.0'

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.1'

androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

此文件显示为/home/users/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/c41e5bc4d98504dc222d4eca88ab6d1b/res/values-v26/values-v26.xml内容

?android:attr/colorError

?android:attr/colorError

true

true

我不知道什么是mmeaning?android:attr / colorError

谢谢

这个问题通常是由于 Android Support 库版本不兼容导致的。解决方法如下: 1. 在 app 模块的 build.gradle 文件中,将 targetSdkVersion 与 compileSdkVersion 版本升级到最新的 Android 版本。 ``` android { compileSdkVersion 31 targetSdkVersion 31 ... } ``` 2. 确保在 dependencies 中使用最新的 Support 库版本。可以在项目根目录下的 build.gradle 文件中设置全局的 Support 库版本: ``` ext { supportLibVersion = "28.0.0" } subprojects { ... dependencies { ... implementation "com.android.support:appcompat-v7:$supportLibVersion" implementation "com.android.support:design:$supportLibVersion" ... } } ``` 然后在 app 模块的 build.gradle 文件中使用该全局变量: ``` dependencies { ... implementation "com.android.support:appcompat-v7:$supportLibVersion" implementation "com.android.support:design:$supportLibVersion" ... } ``` 3. 如果还是出现上述错误,可以尝试使用 AndroidX 库替换 Support 库。在 app 模块的 build.gradle 文件中添加以下代码: ``` android { ... defaultConfig { ... // 添加以下两行 useLibrary 'androidx.core' javaCompileOptions { annotationProcessorOptions { includeCompileClasspath false } } } ... } ``` 然后将 Support 库依赖替换为对应的 AndroidX 库依赖即可。例如: ``` dependencies { ... implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'com.google.android.material:material:1.5.0-alpha01' ... } ``` 以上是解决 AAPT 错误的一些方法,希望能够帮助到你。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值