找不到aapt2-proto.jar(com.android.tools.build:aapt2-proto:0.3.1) [英] Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1)
问题描述
我正在使用Android Studio
处理 tomahawk-android 项目,所以我使用git
将项目直接克隆到Android Studio
中,该项目无法生成,说;
I'm using Android Studio
to work with tomahawk-android project, so i cloned the project using git
, directly into the Android Studio
, where it fails to build, saying;
Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1.jar
build.gradle:
apply plugin: "com.android.application"
android {
implementationSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
def name = readVersionName()
def parts = name.split("[\\._-]")
def code = parts[0] + parts[1]
code = String.format("%-5s", code.substring(0, Math.min(5, code.size()))).replace(' ', '0')
code = Integer.parseInt(code)
versionName name
versionCode code
println("Using version name: $name")
println("Using version code: $code")
}
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
javaMaxHeapSize "2g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.
replace(".apk", "-" + defaultConfig.versionName + ".apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
signingConfigs {
release
}
buildTypes {
release {
zipAlignEnabled true
minifyEnabled true
proguardFiles "../proguard-android.txt"
}
debug {
versionNameSuffix "_debug"
zipAlignEnabled true
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'mips', 'x86', 'x86_64'
universalApk true
}
}
}
// map for the version code
ext.versionCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 4, 'x86': 6, 'x86_64': 7]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.
get(output.getFilter(com.android.build.OutputFile.ABI), 9) * 100000 +
android.defaultConfig.versionCode
println("Using version name: $output.versionCodeOverride")
}
// assign different version name for each output
variant.outputs.each { output ->
def suffix = "_universal"
if (output.getFilter(com.android.build.OutputFile.ABI) != null) {
suffix = "_" + output.getFilter(com.android.build.OutputFile.ABI)
}
output.versionNameOverride = android.defaultConfig.versionName + suffix
}
}
def Properties props = new Properties()
def propFile = file('signing.properties')
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
android.buildTypes.release.signingConfig = android.signingConfigs.release
android.buildTypes.debug.signingConfig = android.signingConfigs.release
}
}
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
implementation group: 'com.android.tools.build', name: 'aapt2-proto', version: '0.1.0'
classpath 'com.android.tools.build:gradle:3.2.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation (name: 'circularprogressview-debug', ext: 'aar')
implementation 'com.android.support:appcompat-v7:24.1.1'
implementation 'com.android.support:support-v4:24.1.1'
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation('ch.acra:acra:4.7.0') {
transitive = false
}
implementation 'com.google.code.gson:gson:2.5'
implementation 'com.google.android.gms:play-services-base:8.4.0'
implementation('com.stanfy:gson-xml-java:0.1.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.7.2'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.7.2'
implementation 'com.squareup.okhttp:logging-interceptor:2.7.2'
implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'
implementation 'de.mrmaffen:vlc-android-sdk:1.9.8'
implementation 'org.apache.lucene:lucene-core:4.7.2'
implementation 'org.apache.lucene:lucene-analyzers-common:4.7.2'
implementation 'org.apache.lucene:lucene-queryparser:4.7.2'
implementation 'commons-io:commons-io:2.4'
implementation 'net.sourceforge.findbugs:jsr305:1.3.7'
implementation 'com.squareup.retrofit:retrofit:1.9.0'
implementation 'com.sothree.slidinguppanel:library:3.2.1'
implementation 'com.uservoice:uservoice-android-sdk:1.2.4'
implementation 'de.greenrobot:eventbus:2.4.1'
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
implementation 'org.jdeferred:jdeferred-android-aar:1.2.4'
implementation 'org.slf4j:slf4j-android:1.7.13'
}
}
allprojects {
repositories {
google() // and here
jcenter()
}
}
gradlew -v
输出:
gradlew -v
output:
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_172 (Oracle Corporation 25.172-b11)
OS: Windows 10 10.0 amd64
谢谢!
推荐答案
这是由于您没有将google()
用作第一回购. google()
的顺序很重要.因此,只需将其添加到 jcenter()
即可解决您的问题.
This is due you didn’t put google()
as the first repo. The order of google()
matters. So just add it above jcenter()
will solve your problem.
请参见 https://stackoverflow.com/a/51151050/8034839
请注意,此更改应在您的 TOP 级别build.gradle
文件中.例如.
Note that this change should be in your TOP level build.gradle
file. E.g.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google() // first one
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google() // first one
jcenter()
}
}
注意:
自从Android Gradle Plugin(AGP)版本3.0.0(Gradle版本4.1+)以来,Google推出了自己的 Google的Maven存储库 google()
,因此大多数依赖项都移到了那里.因此,如果您使用的是AGP 3.0+,则应首先参考此 NEW 存储库.
Since Android Gradle Plugin (AGP) version 3.0.0 (Gradle version 4.1+), Google introduced its own Google's Maven repository google()
, most of the dependencies were moved to there. So, if you are using the AGP 3.0+, you should refer to this NEW repo firstly.
以下是有关不同gradle版本的一些解释:什么是真正的Android Studio Gradle版本?
And here is some explanation about different gradle versions: What is real Android Studio Gradle Version?
这篇关于找不到aapt2-proto.jar(com.android.tools.build:aapt2-proto:0.3.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!