gpt4 book ai didi

android - 找不到 aapt2-proto.jar (com.android.tools.build :aapt2-proto:0. 3.1)

转载 作者:行者123 更新时间:2023-11-29 15:34:52 39 4
gpt4 key购买 nike

我正在使用 Android Studio 来处理 tomahawk-android项目,所以我使用 git 将该项目直接克隆到 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

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 输出:

------------------------------------------------------------
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()即可解决您的问题。

参见https://stackoverflow.com/a/51151050/8034839

请注意,此更改应位于您的 TOP 级别 build.gradle 文件中。例如。

// 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+,您应该首先引用这个存储库。

这里是关于不同 gradle 版本的一些解释:What is real Android Studio Gradle Version?

关于android - 找不到 aapt2-proto.jar (com.android.tools.build :aapt2-proto:0. 3.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52968576/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com