gpt4 book ai didi

java - 如何修复任务 ':app:mergeDebugResources' 执行失败

转载 作者:行者123 更新时间:2023-12-02 05:05:23 29 4
gpt4 key购买 nike

我更新到 Android 3.4,并且正在开发一个 TO-DO 应用程序,当我想运行它时,它给了我这个错误:

Executing tasks: [:app:assembleDebug]

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources FAILED

Execution failed for task ':app:mergeDebugResources'
>1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
C:\Users\CHARAN\Desktop\Android Development\BPTODO\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:11: error: not well-formed (invalid token).
C:\Users\CHARAN\Desktop\Android Development\BPTODO\app\src\main\res\drawable-v24\ic_launcher_foreground.xml: error: file failed to compile.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 35s
8 actionable tasks: 1 executed, 7 up-to-date

我试过了1. 清理和重建2. 使缓存失效并重启3. 改变gradle依赖这就是 android studio 的建议使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。甚至尝试过这个

Gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Gradle(应用程序)


android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.bptodo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}

Activity_main.xml

<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F4F4F4"
tools:context=".MainActivity">


<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#1eea40"
android:layout_height="198dp">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_marginLeft="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/titlepage"
android:layout_marginTop="20dp"
android:textSize="32sp"
android:textColor="#FFF"
android:text="TO DO's"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/subtitlepage"
android:textSize="18sp"
android:textColor="#4A4E6A"
android:layout_marginTop="8dp"
android:text="Finish Them Quickly Today"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>

<Button
android:id="@+id/btnAddNew"
android:layout_width="99dp"
android:layout_height="52dp"
android:layout_marginLeft="60dp"
android:layout_marginTop="35dp"
android:background="@drawable/bgbtnnew"
android:text="+"
android:textAlignment="center"
android:textColor="#FFF"
android:textSize="38sp" />

</LinearLayout>

<View
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:background="#131E69"
android:layout_height="1dp" />

</LinearLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/ourdoes"
android:layout_width="match_parent"
android:layout_marginTop="-60dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_height="wrap_content">

</android.support.v7.widget.RecyclerView>

<TextView
android:id="@+id/endpage"
android:textSize="16sp"
android:textColor="#9A9A9A"
android:layout_marginTop="20dp"
android:text="No More Does"
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

“我希望输出顺利运行,请帮忙”提前致谢

最佳答案

构建>清理项目

或者

./gradlew clean build

或者

在各个应用的 build.gradle 部分 android {} 中,插入:

aaptOptions {  
cruncherEnabled = false
}

关于java - 如何修复任务 ':app:mergeDebugResources' 执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56355446/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com