更新到Android 3.1.1后,当我尝试生成签名的apk时出现此错误:
Could not find com.android.tools.lint:lint-gradle:26.1.1.
Searched in the following locations:
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom
file:/C:/Users/Me/AppData/Local/Android/sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.pom https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.1/lint-gradle-26.1.1.jar
要求: 项目:app
答案 0 :(得分:4)
在我的情况下,只需为所有项目配置添加google()存储库:
allprojects {
repositories {
jcenter()
google()
}
}
答案 1 :(得分:3)
我得到了同样的错误。我能够生成APK,但不是已签名的APK 。
为了能够生成签名的APK,我开始根据https://developer.android.com/studio/build/index.html将/Application/build.grade
分成两个文件。以前我只使用/Application/build.grade
和空/build.gradle
文件。
我的/build.gradle
看起来像是:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
/Application/build.grade
是
apply plugin: 'com.android.application'
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
api 'com.android.support:support-v4:24.1.1'
api 'com.android.support:support-v13:24.1.1'
api 'com.android.support:cardview-v7:24.1.1'
api 'com.android.support:appcompat-v7:24.1.1'
api 'com.android.support:design:24.1.1'
api 'com.google.firebase:firebase-appindexing:10.0.0'
api 'com.itextpdf:itextg:5.5.10'
}
List<String> dirs = ['main', 'common', 'template']
android {
// compileSdkVersion 24
compileSdkVersion 26
// buildToolsVersion '26.0.2'
buildToolsVersion '27.0.3'
defaultConfig {
versionCode 260
versionName "2.60"
minSdkVersion 21
targetSdkVersion 24
applicationId "com.activeng.bluetoothlegatt"
}
signingConfigs {
debug {
storeFile rootProject.file('../keystore.jks')
keyAlias 'activengkey'
keyPassword 'xxxxxxx'
storePassword 'xxxxxxx'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
lintOptions {
abortOnError false
}
}
我在更改文件后完成了“立即同步”,并且我能够再次生成已签名的APK。
答案 2 :(得分:0)
所以,我明白了
更改项目build.gradle中的gradle版本: classpath&#39; com.android.tools.build:gradle:3.1.1&#39; 至 classpath&#39; com.android.tools.build:gradle:3.0.1&#39;
之后我现在从右上角,Clean Project,Rebuild Project做了Sync,然后它生成了标志apk。
但是将版本更改回3.1.1我得到了同样的错误: 找不到com.android.tools.lint:lint-gradle:26.1.1。
事实证明,如果我不允许Android Studio 3.1.1将Android Gradle插件更新到3.1.1版并将Gradle更新到4.4版。以及Android SDK Build Tools 27.0.3然后我可以毫无问题地构建Release版本。
答案 3 :(得分:0)
在allprojects.repositories下添加“google()”后,它对我有用。喜欢这个
allprojects {
repositories {
jcenter()
google()
}
}