Studio无法构建新项目

Studio无法构建新项目

本文介绍了Android Studio无法构建新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

  • 出了什么问题:任务':app:mergeDebugResources'的执行失败.
  • What went wrong:Execution failed for task ':app:mergeDebugResources'.

它找不到一堆文件(确切地说,还有很多):

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.

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

Did i missed something? I also reinstalled Android Studio on different paths, but that didnt fixed anything.

这是构建平台

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

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

这是我的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字符时遇到问题.

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.

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

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.

这篇关于Android Studio无法构建新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 01:04