我正在使用AgeGroupCollection
处理tomahawk-android项目,因此我使用AgeGroupId
将项目克隆到Android Studio
中,但无法建立,说;
git
build.gradle:
Android Studio
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
输出:
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()
}
}
谢谢!
答案 0 :(得分:3)
这是由于您没有将annotation
用作第一回购。 google()
的顺序很重要。因此,只需在 上方添加google()
即可解决您的问题。
请参见https://stackoverflow.com/a/51151050/8034839
请注意,此更改应在您的 TOP 级jcenter()
文件中。例如。
build.gradle
注意:
自从Android Gradle Plugin(AGP)版本3.0.0(Gradle版本4.1+)以来,Google推出了自己的 Google的Maven存储库 // 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()
}
}
,因此大部分依赖项都移到了那里。因此,如果您使用的是AGP 3.0+,则应首先参考此 NEW 存储库。
以下是有关不同gradle版本的一些解释:What is real Android Studio Gradle Version?
答案 1 :(得分:1)
感谢@HedeH,他将我链接到他的回答here,说:
尝试将google()方法(所有.gradle文件中的)移动到 它的执行块。
我在搜索该问题之前确实看到了该答案,但是我错过了必须将其更改为“ 在所有.gradle文件中”的问题。