我尝试将我的应用程序更新为sdk版本28,并且不断出现此错误:
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
我尝试重新构建应用程序,更新构建工具并分别实现CoordinatorLayout。我真的不知道为什么会给我这个错误,它适用于SDK版本27。
我的build.gradle文件是否做错了什么?:
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'
}
对于我正在使用的CoordinatorLayout,这是.xml文件:
<?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>
有人可以解决我的问题吗?
答案 0 :(得分:5)
错误:资源样式/Widget.Design.CoordinatorLayout(又名de.test.browserelement:
style/Widget.Design.CoordinatorLayout
)未找到。
转到您的values.xml
并进行以下更改:
style/Widget.Design.CoordinatorLayout
收件人:
@style/Widget.Support.CoordinatorLayout
例如:
<item name="coordinatorLayoutStyle">@style/Widget.Support.CoordinatorLayout</item>