android - 获取 Android 资源链接失败
问题描述
我们正在构建一个android项目,当我们尝试构建项目时,我们得到Android资源构建失败
出于奇怪的原因,它指向的文件不是我们项目的一部分,位于
C:\location.gradle\caches\transforms-2\files-2.1\87cdecd973dcf2cf22fdc9f513d1a506\RoundKornerLayouts-0.4.0\res\values\values.xml:4:5-258: AAPT: error: resource attr/top_left_corner_radius (aka com .package.android:attr/top_left_corner_radius) 未找到
我们尝试了以下解决方案,但没有奏效
我们不知道为什么会出现这个错误以及背后的原因是什么!粘贴 gradle 文件以获取更多详细信息
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
//classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
url 'https://github.com/psiegman/mvn-repo/raw/master/releases'
}
maven {
url "http://dl.bintray.com/mobisystech/maven"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}}
应用构建.gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "in.studentkhabri.android"
manifestPlaceholders = [onesignal_app_id : 'hidden',
onesignal_google_project_number: 'REMOTE',
hostName : 'host_name'
]
minSdkVersion 17
targetSdkVersion 27
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.zsoltsafrany:needle:1.0.0'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.github.nihad92:SwipeableCards:1.0.19'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.ncorti:slidetoact:0.5.1'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.mindorks.android:prdownloader:0.5.0'
implementation 'net.bohush.geometricprogressview:geometricprogressview:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation 'com.devbrackets.android:exomedia:4.3.0'
//implementation 'com.dinuscxj:circleprogressbar:1.3.0'
//implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
implementation 'commons-io:commons-io:2.4'
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
//implementation 'com.jaeger.statusbarutil:library:1.5.1'
implementation 'com.github.iammert:MusicPlayerView:e3b937c729'
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'
implementation 'com.google.android.exoplayer:extension-rtmp:2.9.1'
implementation 'com.cleveroad:audiowidget:1.0.1'
implementation 'jp.wasabeef:glide-transformations:4.0.1'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.github.caneryilmaz:ZionFileDownloader:0.1.1'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.jcminarro:RoundKornerLayouts:0.4.0'
implementation 'com.github.sujithkanna:smileyrating:1.6.8'
implementation 'org.apache.commons:commons-lang3:3.0'
//implementation 'com.github.mosamabinomar:AndroidEqualizer:1.0'
//implementation 'com.ogaclejapan.smarttablayout:library:1.7.0@aar'
implementation project(':ProgressDialog')
implementation 'com.github.ixiDev:GDPRChecker:v0.2'
implementation 'com.google.android.ads.consent:consent-library:1.0.3'
implementation 'ru.tinkoff.scrollingpagerindicator:scrollingpagerindicator:1.0.6'
implementation 'net.alexandroid.utils:exoplayerhelper:2.18'
implementation 'com.google.firebase:firebase-ads:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-dynamic-links:16.1.7'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}}
解决方案
这个错误绝对不是什么严重的错误。当 Gradle 在一个或多个 XML 文件中遇到错误(通常是语法或拼写错误)时,就会出现该错误。
大多数 XML 文件都位于 res 文件夹中,但是,您可能仍会在 res 文件夹之外找到一些文件。例如,位于“/src/main/AndroidManifest.xml”中的 AndroidManifest.xml。这是一个布局文件示例,它会给出“错误:链接文件资源失败”错误。
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:angle="90"
android:centerColor="@color/colorPrimaryDark"
android:endColor="@color/colorPrimaryDark"
android:startColor="@color/colorPrimaryDark"
android:endCollor="@color/colorPrimaryDark"
android:type="linear" />
<corners
android:radius="10dp"/>
</shape>
注意“android:endCollor”属性。
解决方案
您所要做的就是检查每个 XML 文件以找出错误可能出在哪里。这有时可能很耗时,但请放心,一旦您找到并修复问题子项(问题 XML),错误就会消失。
你可能很幸运,Android Studio 会为你指明确切的方向。其他时候,比如当你使用旧版本的 Android Studio 时,错误不会是这个特定的。就是这样。我希望你能弄清楚。
推荐阅读
- python - 从一列熊猫数据框创建字典
- c++ - 用数组覆盖数组
- swift - 如何查询firebase数据childByAutoID?
- variables - 通过 Ansible “terraform” 模块执行 Terraform。需要的字符串集
- python - 如何在 django admin 主模板上添加按钮?
- apache-spark - 当 Spark 发现一个动作时,会运行每一行代码,直到该动作或仅与该动作相关的转换?
- dompdf - dompdf 文档和示例到哪里去了?
- c# - 将 listView 表导出到 Excel
- python - 如何在以下代码中修复 Python 中的“int object is not subscriptable”?
- postgresql - 选择组内具有第二高值的行