我在更新构建工具之后收到此错误,如下所示:
从2.2.3到4.1的gradle从更新的distributionUrl gradle-2.14.1-all.zip to gradle-4.1-all.zip
Android插件版本 从2.2.3到3.0.1
我的android studio:3.0.1
有人可以建议我在哪里做错了。有什么事我需要更新吗?
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
import org.ajoberstar.grgit.Grgit
plugins {
id 'me.tatarka.retrolambda' version '3.2.3'
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven {url "https://jitpack.io"}
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'findbugs'
apply plugin: 'pmd'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'commons-lang:commons-lang:2.3'
compile ('com.google.apis:google-api-services-youtube:v3-rev162-1.21.0'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'eu.chainfire:libsuperuser:1.0.0.201510071325'
compile 'commons-io:commons-io:2.4'
compile 'commons-net:commons-net:3.3'
compile 'org.apache.commons:commons-collections4:4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.8'
compile 'io.reactivex:rxjava:1.0.14'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'net.sourceforge.streamsupport:streamsupport:1.6.0'
compile 'org.zeroturnaround:zt-zip:1.8'
compile 'dnsjava:dnsjava:2.1.7'
compile 'com.neovisionaries:nv-websocket-client:1.9'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'junit:junit:4.10'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.lecho:hellocharts-android:v1.5.8'
compile 'com.jakewharton:process-phoenix:2.0.0'
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
testOptions {
unitTests.returnDefaultValues = true
}
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "XXXX"
minSdkVersion 19
multiDexEnabled true
def majorVersion = 15
def midVersion = 0
def minorVersion = 0
def branchName = getGitBranchName()
versionCode getJenkinsBuildNumber()
versionName "$majorVersion.$midVersion.$minorVersion-$branchName-$versionCode"
}
// Run lint checks but don't abort build
lintOptions {
abortOnError false
}
signingConfigs {
releaseConfig {
storeFile file("../xxxx.jks");
storePassword("xxx");
keyAlias "xxxx";
keyPassword "xxx";
}
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.releaseConfig
applicationVariants.all { variant ->
variant.outputs.each { output ->
String parentDir = output.outputFile.parent
String newName = output.outputFile.name.replace("app-release", "xxxx-${variant.versionName}")
output.outputFile = new File(parentDir, newName)
}
}
}
debug {
initWith release
debuggable true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
abortOnError false
ignore 'InvalidPackage' //to ignore lint errors in Okio and StreamSupport
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
sourceSets {
test {
resources {
srcDirs = ['src/test/resources']
}
}
}
}
dexcount {
includeClasses = false
includeFieldCount = false
printAsTree = true
orderByMethodCount = true
verbose = false
}
task buildHelperDebug(type: GradleBuild) {
dir = '../systemhelper'
tasks = ['assembleDebug']
}
task copyHelperDebug(type: Copy, dependsOn: buildHelperDebug) {
File apkFile = file('src/main/assets/systemhelper-debug.apk')
if (apkFile.exists()) {
apkFile.delete();
}
from '../systemhelper/build/outputs/apk/systemhelper-debug.apk'
into 'src/main/assets'
}
task buildHelperRelease(type: GradleBuild) {
dir = '../systemhelper'
tasks = ['assembleRelease']
}
task copyHelperRelease(type: Copy, dependsOn: buildHelperRelease) {
File apkFile = file('src/main/assets/systemhelper-release.apk')
if (apkFile.exists()) {
apkFile.delete();
}
from '../systemhelper/build/outputs/apk/systemhelper-release.apk'
into 'src/main/assets'
}
preBuild.dependsOn copyHelperDebug
preBuild.dependsOn copyHelperRelease
task findbugs(type: FindBugs, dependsOn: assemble) {
description 'Run findbugs'
group 'verification'
classes = fileTree('build/intermediates/classes/debug/')
source = fileTree('src/main/java')
classpath = files()
effort = 'max'
excludeFilter = file("findbugs-exclude.xml")
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = false
}
}
task pmd(type: Pmd) {
description 'Run pmd'
group 'verification'
ruleSets = ["java-basic", "java-braces", "java-strings", "java-design", "java-unusedcode"]
source = fileTree('src/main/java')
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = false
}
}
task checkHelper(type: GradleBuild) {
dir = '../systemhelper'
tasks = ['check']
}
check.dependsOn(['pmd', 'findbugs', 'checkHelper'])
def getGitBranchName() {
System.getenv("GIT_BRANCH")?.replace("origin/", "")?.replace("gitlab/", "") \
?: Grgit.open()?.branch?.getCurrent()?.name \
?: "no-branch"
}
def getJenkinsBuildNumber() {
System.getenv("BUILD_NUMBER") as Integer ?: 0
}
答案 0 :(得分:0)
我找到了解决方案。这个答案可能对其他人有帮助。必须同步编译sdk和构建工具版本。
在root项目中,gradle添加了google存储库。
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
并更改了构建工具版本并编译了sdk
compileSdkVersion 24
buildToolsVersion '24.0.1'
清理并重新构建应用程序。这将解决兼容性问题。