已修订:升级到AS(3.2.1)和Gradle(4.6)后出现新错误。
这是build.gradle代码。 Gradle属性具有“ android.enableAapt2 = true”,并且包装器属性具有“ distributionUrl = https://services.gradle.org/distributions/gradle-4.6-all.zip”
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/CHANGES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId "com.abc.app"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
multiDexEnabled true
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2048M"
}
configurations {
all*.exclude module: 'mediarouter-v7'
all*.exclude module: 'support-compat'
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'ch.acra:acra:4.9.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:multidex:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:percent:28.0.0'
implementation 'com.google.android.gms:play-services:10.2.1'
implementation 'com.google.android.gms:play-services-gcm:10.2.1'
implementation 'com.google.android.gms:play-services-ads:10.2.1'
implementation 'com.google.android.gms:play-services-auth:10.2.1'
implementation 'com.google.maps.android:android-maps-utils:0.3.+'
implementation 'de.hdodenhof:circleimageview:1.3.0'
implementation 'com.jakewharton:butterknife:8.5.1'
implementation 'com.uber.sdk:rides-android:0.5.3'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'org.jsoup:jsoup:1.11.3'
testImplementation 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
apply plugin: 'com.google.gms.google-services'
新错误是
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_btn_colored_text_material.xml:20: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_btn_checkable.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_default.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_edittext.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_seek_thumb.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_spinner.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_switch_track.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_switch_track.xml:20: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\888450102b7519d6fb3ec4fed42688ef\res\color\abc_tint_switch_track.xml:21: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\design-28.0.0.aar\d2abd1d1eab13b237ffd0fc5d63d6820\res\color\design_tint_password_toggle.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media.xml:23: error: resource layout/notification_template_icon_group (aka com.abc.app:layout/notification_template_icon_group) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media.xml:23: error: resource dimen/notification_large_icon_height (aka com.abc.app:dimen/notification_large_icon_height) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media.xml:23: error: resource dimen/notification_large_icon_width (aka com.abc.app:dimen/notification_large_icon_width) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media.xml:34: error: resource dimen/notification_large_icon_width (aka com.abc.app:dimen/notification_large_icon_width) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media.xml:34: error: resource dimen/notification_large_icon_width (aka com.abc.app:dimen/notification_large_icon_width) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media_custom.xml:23: error: resource layout/notification_template_icon_group (aka com.abc.app:layout/notification_template_icon_group) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media_custom.xml:23: error: resource dimen/notification_large_icon_height (aka com.abc.app:dimen/notification_large_icon_height) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media_custom.xml:23: error: resource dimen/notification_large_icon_width (aka com.abc.app:dimen/notification_large_icon_width) not found.
C:\Users\<User>\.gradle\caches\transforms-1\files-1.1\support-media-compat-28.0.0.aar\f0a6c1a9d43f0b2d6cca2c26c28e9e86\res\layout\notification_template_big_media_custom.xml:34: error: resource dimen/notification_large_icon_height (aka com.abc.app:dimen/notification_large_icon_height) not found.
尝试了许多解决方案,包括使缓存无效/重新启动,关闭和导入项目,删除缓存文件,重新安装Android Studio,清理和重建。它们都无法使项目成功构建。
还有其他可能的解决方案吗?
答案 0 :(得分:0)
尝试删除您的gradle
缓存。例如,在Windows上:
C:\Users\[username]\.gradle\caches
然后执行以下操作:
Android Studio>File>Sync with File System
Android Studio>File>Sync Project with Gradle Files
Android Studio>Build> Clean Project
Android Studio>Build> Rebuild Project
答案 1 :(得分:0)
在找不到错误源的情况下,尝试创建一个新项目,然后,首先,仅将.java
文件复制到新项目中,然后再尝试复制{{1} }和layout
文件夹。
然后尝试在drawable
文件中逐个同步添加dependencies
在build.gradle
文件中,以查看是哪个引起了问题。
我还要在您的build.gradle
中提及一些建议:
首先将这一行移到顶部:
apply plugin: 'com.google.gms.google-services'
在apply plugin: 'com.android.application'
之后
我也建议您迁移到Androidx而不是支持库。
我也不再使用杰克沃顿的黄油刀了。现在,Android中有视图绑定。使用它:解释here