android - Android Studio无法构建新项目

标签 android gradle android-studio-3.0

Iam是Android Studio的新手。我做了一个全新的安装,但我什至无法构建一个新的Project。还安装了Java RE和JDK。

失败:生成失败,发生异常。

  • 出了什么问题:
    任务':app:mergeDebugResources'的执行失败。

    Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details


  • 它找不到一堆文件(确切地说还有很多):
    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.
    

    我错过了什么吗?我还在不同的路径上重新安装了Android Studio,但这并没有解决任何问题。

    这是构建 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
    }
    

    这是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'
     }
    

    这是我的xml文件
    <?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>
    

    最佳答案

    看起来您的用户名中包含非ASCII字符,这也导致文件路径也包含该字符。 AAPT2当前在解析Windows上的非ASCII字符时遇到问题。

    如果尝试使用最新的Android Studio 3.2 alpha,则可以使用一个实验性的标志:可以在gradle.properties文件中添加android.useAapt2FromMaven=true。这仅在最新的android gradle插件(3.2 alpha 9或更高版本)中有效,因此您需要更新android studio和android gradle插件版本。

    关于android - Android Studio无法构建新项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49652712/

    相关文章:

    android - 'flavorDimension' 将被 Android Gradle Plugin 2.0 移除,它已被 'dimension' 取代

    java - 如何将数据从 SQlite 导出到 CSV 或 Excel 或其他格式?

    java - Matcher 会跳过第一场比赛吗?或者我做错了什么

    android - 无法使用 Android Studio 3.0 + DataBinding + Kotlin 构建项目

    android - 如何更改不同的 URL 或在选项卡式 Activity 中查看?

    java - 尝试运行 Android SDK 时出现 Mac Java 路径问题

    android - 如何在 Android 中同步两个 ScrollView ?

    javascript - 页面更改在使用 Phonegap Build 的 Android 上的 JqueryMobile 中不起作用

    docker - 容器化Spring Boot应用程序时的Docker错误

    intellij-idea - 无法注册类型为 'SOURCE' 的给定路径,因为它超出了内容根目录