Android Studio 4.1更新后应用程序的渐变生成错误

Android Studio 4.1更新后应用程序的渐变生成错误,android,android-studio,gradle,Android,Android Studio,Gradle,我已经从Android Studio 4.0升级到4.1。更新之后,我无法再构建在更新之前运行良好的应用程序。 当我构建项目时,我会遇到以下异常: 失败:生成失败,出现异常。 出了什么问题: 任务“:app:compressDebugAssets”的执行失败。 执行com.android.build.gradle.internal.tasks.CompressAssetsWorkAction时出错 my\application\path\app\build\intermediates\merge

我已经从Android Studio 4.0升级到4.1。更新之后,我无法再构建在更新之前运行良好的应用程序。 当我构建项目时,我会遇到以下异常:

失败:生成失败,出现异常。

出了什么问题:
任务“:app:compressDebugAssets”的执行失败。
执行com.android.build.gradle.internal.tasks.CompressAssetsWorkAction时出错 my\application\path\app\build\intermediates\merged\u assets\debug\out

文件夹my\application\path\app\build\intermediates\merged\u assets\debug\out为空

我想做的是:

  • 清理和重建项目
  • 删除.gradle和build文件夹,并清理重建项目
  • 使Android studio无效并重新启动
  • 将gradle.properties中的堆大小增加到:org.gradle.jvmargs=-Xmx4096m
  • 增加了CompileSDK版本和TargetSDK版本
  • 已安装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成功构建所需的某些依赖项,需要下载这些依赖项。因此,请确保您的计算机处于联机状态

->点击gradle(android studio的右侧),然后切换下图中突出显示的按钮

  • 确保其未突出显示,因为如果突出显示,则表示gradle处于脱机状态(无法访问internet)

  • 然后重建项目以下载缺少的gradle依赖项


  • 我希望您会觉得这很有用。

    我找到了一个临时解决方案,将我的Android Studio版本降级到4.0.2。
    此外,我将Android gradle插件版本更改为4.0.2,将gradle版本更改为我之前安装的6.1.1。您可以在文件->项目结构->项目下执行此操作。
    现在我可以再次运行我的应用程序了。我知道这只是一个临时解决方案,但至少我可以重新处理我的应用程序。

    我将在接下来的几天内尝试安装安卓Studio 4.2 Canary 15,并检查是否适合我。我会告诉你的。

    这个解决方案可能会有所帮助。我在出现这个错误时遇到了问题,我不知道为什么。事实证明,我将android项目保存到U盘上。U盘是用PAL格式化的。我用NTFS重新格式化,问题就解决了。

    今天早上更新Android studio后,我遇到了类似的问题。在我的例子中,以前的项目运行得很好,但是如果我创建了一个新项目并尝试运行,我会收到上面提到的错误消息。我从“项目结构”对话框中将Android Gradle插件版本更改为4.0.2,将Gradle版本更改为6.1.1,之后我成功地运行了该应用程序。

    将我的项目位置从FAT32格式的驱动器更改为NTFS驱动器为我解决了问题。

    谢谢您的回答。不幸的是,这对我来说并不奏效。按钮已经没有突出显示,我有一个稳定的互联网连接。我不确定格式化USB记忆棒是否可以修复Android Studio迁移。似乎你在其他方面做得很好,但没有注意到这是一个修复:)你的gradle和android插件版本是什么?你的
    minSdkVersion
    是23,你不需要
    implementation'androidx.multidex:multidex:2.0.1'
    vectorDrawables{useSupportLibrary=true}
    。尝试移除它们。