[英]Android Studio project sync FAILED
I attempted to import a project that Udacity's android course provided, but there were some issues. 我尝试导入Udacity的android课程提供的项目,但是存在一些问题。 In the build.grade(app module)
I changed compile
to implementation
and testCompile
to testImplementation
. 在build.grade(app module)
我将compile
更改为implementation
,将testCompile
更改为testImplementation
。 The project synced successfully, but when I executed the project on the emulator it gave me the following errors. 该项目成功同步,但是当我在模拟器上执行该项目时,出现了以下错误。
Could not find com.android.tools.build:aapt2:3.3.1-5013011.
Searched in the following locations:
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
Required by:
project :app
I think the required libraries needed to build cannot be found, but I don't know how to solve this. 我认为无法找到构建所需的必需库,但是我不知道该如何解决。 I googled the problem, but I can't find a solution. 我在问题上进行了搜索,但找不到解决方案。 My build.gradle file is this: 我的build.gradle文件是这样的:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
api 'com.android.support:appcompat-v7:23.3.0'
api 'com.android.support:support-v4:23.3.0'
api 'com.android.support:design:23.3.0'
}
build.grade(project) is: build.grade(项目)是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Beginning with Android Studio 3.2, the source for AAPT2 (Android Asset Packaging Tool 2) is Google's Maven repository. 从Android Studio 3.2开始,AAPT2(Android资产打包工具2)的来源是Google的Maven存储库。
To use AAPT2, make sure that you have a google() dependency in your build.gradle file. 要使用AAPT2,请确保您的build.gradle文件中具有google()依赖项。
allprojects {
repositories {
google()
jcenter()
}
}
Check the official documentation . 检查官方文档 。
The AAPT2 (Android Asset Packaging Tool) is a build tool that Android Studio and Android Gradle Plugin. AAPT2(Android资产打包工具)是Android Studio和Android Gradle插件的构建工具。
Android Gradle Plugin 3.0.0 and higher enable AAPT2 by default. Android Gradle Plugin 3.0.0和更高版本默认情况下启用AAPT2。
With Android Studio 3.2 to use AAPT2, make sure that you have a google()
dependency in your build.gradle
: 使用要使用AAPT2的Android Studio 3.2 ,请确保build.gradle中具有google()
依赖build.gradle
:
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
} allprojects {
repositories {
google() // and here
jcenter()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.