【发布时间】:2021-01-05 07:50:28
【问题描述】:
我收到以下错误。
Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file not found.
但 .png 文件存在于 mipmap-hdpi(mdpi)(xhdpi)(xxhdpi)(xxxhdpi)
构建中的完整错误如下\
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.1-6503028-windows Daemon #3: Unexpected error during compile 'C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-mdpi\ic_launcher_round.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-hdpi\ic_launcher.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.1-6503028-windows Daemon #2: Unexpected error during compile 'C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-xhdpi\ic_launcher.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.1-6503028-windows Daemon #4: Daemon startup failed
Please check if you installed the Windows Universal C Runtime.
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-xhdpi\ic_launcher_round.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.1-6503028-windows Daemon #5: Daemon startup failed
Please check if you installed the Windows Universal C Runtime.
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: file not found.
* 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 6s
20 actionable tasks: 1 executed, 19 up-to-date
我尝试了以下事情
-使缓存无效并重新启动 Android Studio
-卸载并重新安装 Android Studio
- 更新了 build.gradle 中的所有文件
-清理和重建项目
- 即使在 Manisfest 页面中更改了 android:icon 和 android:roundicon\
清单页面如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.xd">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Xd">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我没有对 MainActivity 和 activity_main.xml 进行任何更改
我使用的类路径是classpath "com.android.tools.build:gradle:4.1.1"
build.gradle(Module)如下:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.xd"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
【问题讨论】:
-
检查
res\mipmap-mdpi\ic_launcher.png上的文件ic_launcher.png还在吗? -
可能是你弄乱了应用的图标文件。尝试替换图标文件。
-
我已经更新了显示特定文件夹中文件的问题,我可以在 Windows 中打开它们。
-
Users或OneDrive文件夹可能受到保护,因此工具无权定位文件。尝试将项目从他们那里移出? -
@AndrewT。在另一个驱动程序中创建新项目后。我面临这个错误。\
Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > AAPT2 aapt2-4.1.1-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon. This should not happen under normal circumstances, please file an issue if it does.
标签: java android xml android-studio