问题
Iam completly new to Android Studio. I did a fresh installation, but i cant even build a fresh Project. Java RE and JDK are also installed.
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
it fails to find a bunch of files( a lot more to be exact):
C:\Users\Kevin Me?mer\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.0.aar\772b859d9774811adda23f9733ce921e\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png: error: file not found.
C:\Users\Kevin Me?mer\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.0.aar\772b859d9774811adda23f9733ce921e\res\drawable-mdpi-v4\abc_switch_track_mtrl_alpha.9.png: error: file not found.
C:\Users\Kevin Me?mer\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.0.aar\772b859d9774811adda23f9733ce921e\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png: error: file not found.
Did i missed something? I also reinstalled Android Studio on different paths, but that didnt fixed anything.
Here is the Build Gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// 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
}
And here is the Build Gradle Modul:app
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.kevinmemer.myapplication"
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
Here is additionally my xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
回答1:
Looks like you have a non-ascii character in your username, which is causing the file path to contain that as well. AAPT2 currently has trouble parsing non-ascii characters on windows.
There's an experimental flag you could use if you try the newest Android Studio 3.2 alphas: you can add android.useAapt2FromMaven=true
in your gradle.properties file. This will work only in the newest android gradle plugin (3.2 alpha 9 or newer), so you need to update your android studio and android gradle plugin version.
来源:https://stackoverflow.com/questions/49652712/android-studio-cant-build-a-fresh-project