【发布时间】:2021-02-09 21:31:16
【问题描述】:
我已从 Android Studio 4.0 更新到 4.1。更新后,我无法再构建我的应用程序,这在更新之前运行良好。 当我构建项目时,出现以下异常:
失败:构建失败并出现异常。
出了什么问题:
任务“:app:compressDebugAssets”执行失败。
执行 com.android.build.gradle.internal.tasks.CompressAssetsWorkAction 时发生故障 my\application\path\app\build\intermediates\merged_assets\debug\out
文件夹 my\application\path\app\build\intermediates\merged_assets\debug\out 为空。
我想做什么:
- 清理并重建项目
- 删除 .gradle 和 build 文件夹并清理并重建项目
- 使 Android Studio 失效并重新启动
- 将 gradle.properties 中的堆大小增加到:org.gradle.jvmargs=-Xmx4096m
- 增加了 compileSdkVersion 和 targetSdkVersion
- 安装并更新 buildToolsVersion 从 30.0.0 到 30.0.2
- 在我的配置中添加了 multiDexEnabled true
我的 gradle 配置如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-R'
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "my.application.id"
minSdkVersion 23
targetSdkVersion 29
versionCode 2
versionName "1.1"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.multidex:multidex:2.0.1'
}
伙计们,我没有想法,因为我不是 gradle 方面的专家。非常感谢您的帮助。
【问题讨论】:
-
你的 gradle 和 android 插件版本是什么?
-
您的
minSdkVersion是 23,您不需要implementation 'androidx.multidex:multidex:2.0.1'和vectorDrawables { useSupportLibrary = true}。尝试删除它们。
标签: android android-studio gradle