N S*_*AND 7 java xml android android-studio
我收到以下错误。
Android resource compilation failed
C:\Users\sarat\OneDrive\Desktop\xd\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file not found.
Run Code Online (Sandbox Code Playgroud)
但 .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
Run Code Online (Sandbox Code Playgroud)
我尝试了以下操作
- 使缓存无效并重新启动 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>
Run Code Online (Sandbox Code Playgroud)
我没有对 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'
}
Run Code Online (Sandbox Code Playgroud)
好吧,对我来说 降级类路径
从 "com.android.tools.build:gradle:4.1.1"
到"com.android.tools.build:gradle:4.0.2"为我工作。
感谢所有帮助过我的人。
| 归档时间: |
|
| 查看次数: |
6448 次 |
| 最近记录: |