java - 如何修复任务':app:mergeDebugResources'的执行失败
问题描述
我更新到 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 建议的
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.
,甚至尝试过
摇篮(项目)
// 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
}
摇篮(应用程序)
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
}
推荐阅读
- c# - 为什么我不能使用 C# winforms 在新窗口中打开网页?
- mysql - 为什么 Mysql Rand() 在使用左连接时有不同的行为
- typescript - 使用打字稿在本机反应中从状态更新样式
- python - 使用输入在python中绘制线条
- amazon-web-services - 将 ECS 服务日志转发到 AWS CloudWatch 的正确方法是什么?
- python - Pandas 合并后解决重复问题
- php - 在 if 语句中的其他块内调用 php 块
- automated-tests - Fitnesse 忽略方法的结果
- fastapi - FastAPI 持久化数据库连接
- opencl - 使用opencl的相关矩阵