Ошибка: невозможно загрузить класс 'org.gradle.logging.StyledTextOutput $ Style' - PullRequest
0 голосов
/ 04 мая 2018

Я получаю эту ошибку после обновления инструментов сборки, как показано ниже:

Gradle с 2.2.3 до 4.1
Обновленный дистрибутивUrl с gradle-2.14.1-all.zip для gradle-4.1-all.zip
Версия плагина Android с 2.2.3 до 3.0.1
Моя андроид студия: 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
}

1 Ответ

0 голосов
/ 15 мая 2018

Я нашел решение. Этот ответ может помочь другим. Компиляция SDK и версия инструмента сборки должны быть синхронизированы.

В корневой проект 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'

очистить и заново собрать приложение. это решит проблемы совместимости.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...