Android Studio resource linking failed

匿名 (未验证) 提交于 2019-12-03 01:09:02

问题:

I tried to update my app to sdk version 28 and I am constantly getting this error:

Android resource linking failed Output:  C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2641: error: resource style/Widget.Design.CoordinatorLayout (aka de.test.browserelement:style/Widget.Design.CoordinatorLayout) not found. error: failed linking references.  Command: C:\Users\nick\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\cbd40259f1851f4cf906e8ce48516057\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\         C:\Users\nick\AppData\Local\Android\Sdk\platforms\android-28\android.jar\         --manifest\         C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\         -o\         C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\         -R\         @C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\         --auto-add-overlay\         --java\         C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\         --custom-package\         de.test.browserelement\         -0\         apk\         --output-text-symbols\         C:\Users\nick\AndroidStudioProjects\BrowserElement\app\build\intermediates\symbols\debug\R.txt\         --no-version-vectors     Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0 

I tried rebuilding the app, updating the build tools and implementating the CoordinatorLayout separately.I don't really know why it is giving me this error, it worked for SDK version 27.

Did I do something wrong with my build.gradle file?:

apply plugin: 'com.android.application'  android {  compileSdkVersion 28 defaultConfig {     applicationId "de.test.browserelement"     minSdkVersion 19     targetSdkVersion 28     versionCode 1     versionName "1.0"     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"     vectorDrawables.useSupportLibrary = true } buildTypes {     release {         minifyEnabled false         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'     } } }  dependencies {     implementation fileTree(dir: 'libs', include: ['*.jar'])     implementation 'com.android.support:appcompat-v7:28.0.0'     implementation 'com.android.support.constraint:constraint-layout:1.1.3'     implementation 'com.android.support:design:28.0.0'     implementation 'com.android.support:support-v4:28.0.0'     implementation 'com.android.support:support-vector-drawable:28.0.0'     implementation 'com.android.support:preference-v7:28.0.0'     implementation 'me.dm7.barcodescanner:zxing:1.9.8'     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' } 

And for the CoordinatorLayout I am using, here is the .xml file:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> </android.support.design.widget.CoordinatorLayout> 

Does anyone have a solution for my problem?

回答1:

error: resource style/Widget.Design.CoordinatorLayout (aka de.test.browserelement:style/Widget.Design.CoordinatorLayout) not found.

Go to your values.xml and change this:

style/Widget.Design.CoordinatorLayout 

To:

@style/Widget.Support.CoordinatorLayout 

For example:

<item name="coordinatorLayoutStyle">@style/Widget.Support.CoordinatorLayout</item> 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!