ask :app:processDebugResources FAILED Execution failed for task修复

新建项目报错 > Task :app:processDebugResources FAILED Execution failed for task

具体报错:

Task :app:processDebugResources FAILED Execution failed for task ‘:app:processDebugResources’. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed error: failed to open APK: Invalid file.

百度了很久,只说了了gradle的版本对应不上,没有别的提示,所以只能按照可以运行的就想买设置

buildscript {
    ext {
        agp_version = '7.4.2'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.0.1' apply false
    id("org.jetbrains.kotlin.android") version "1.6.21" apply false
}
defaultConfig {
        applicationId "com.example.testwebsocket"
        minSdk 28
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

然后又报错:

issues were found when checking AAR metadata:1. Dependency ‘androidx.appcompat:appcompat-resources:1.6.1’ requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs. :app is currently compiled against android-31.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application’s compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency ‘androidx.appcompat:appcompat:1.6.1’ requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-31.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application’s compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
minSdkVersion (which determines which devices the app can be installed

换到旧依赖代码

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.appcompat:appcompat-resources:1.4.0'
    implementation 'androidx.emoji2:emoji2-views-helper:1.1.0'
    implementation 'androidx.emoji2:emoji2:1.1.0'
    implementation 'androidx.core:core:1.6.0'
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.annotation:annotation-experimental:1.1.0'
     implementation 'com.google.android.material:material:1.5.0'
    // 其他依赖...
}

最后又报资源问题:

Execution failed for task ‘:app:processDebugResources’.
A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
com.example.testwebsocket.app-mergeDebugResources-16:/values/values.xml:1723: error: resource attr/colorPrimaryVariant (aka com.example.testwebsocket:attr/colorPrimaryVariant) not found.
error: resource style/Theme.MaterialComponents.DayNight.DarkActionBar (aka com.example.testwebsocket:style/Theme.MaterialComponents.DayNight.DarkActionBar) not found.

解决:针对不对的地方进行添加,再重新构建即可

  • 31
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值