修订:升级到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>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_btn_colored_text_material.xml:20: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_btn_checkable.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_default.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_edittext.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_seek_thumb.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_spinner.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_switch_track.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_switch_track.xml:20: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aar888450102b7519d6fb3ec4fed42688efrescolorabc_tint_switch_track.xml:21: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1design-28.0.0.aard2abd1d1eab13b237ffd0fc5d63d6820rescolordesign_tint_password_toggle.xml:19: error: attribute alpha (aka com.abc.app:alpha) not found.
C:Users<User>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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>.gradlecachestransforms-1files-1.1support-media-compat-28.0.0.aarf0a6c1a9d43f0b2d6cca2c26c28e9e86reslayoutnotification_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、Clean&重建他们中没有一个人能够成功地完成这个项目。
还有其他可能的解决方案吗?
尝试删除gradle
缓存。例如,在Windows:上
C:Users[username].gradlecaches
然后执行以下操作:
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
在这种找不到错误源的情况下,请尝试创建一个新项目,然后首先,只将.java
文件复制到新项目中,然后,尝试复制layout
和drawable
文件夹。然后尝试在build.gradle
文件中逐个添加dependencies
,每次添加后同步,看看是哪一个导致了问题。
此外,我应该在你的build.gradle
:中提到一些建议
首先将这一行移到顶部:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
之后
此外,我建议您迁移到Androidx,而不是支持库。
我也不会再使用杰克的黄油刀了。现在Android中有视图绑定。使用:在这里解释