项目刷新失败 - 错误:原因:org / gradle / internal / TrueTimeProvider

时间:2017-06-06 13:41:20

标签: android android-studio gradle

从github导入这个项目,我已经碰到了这条消息:

Gradle 'GameOfLife-master' project refresh failed
Error:Cause: org/gradle/internal/TrueTimeProvider

我尝试过发布here的解决方案,清理/重建(至少尝试过)项目,无效的缓存并尝试了不同版本的Gradle。这些都没有效果。其他人有什么想法吗?

模块:app - build.gradle

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath "com.neenbedankt.gradle.plugins:android-apt:1.8"
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'
        classpath "net.rdrei.android.buildtimetracker:gradle-plugin:0.5.+"
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'hu.supercluster:paperwork-plugin:1.2.7'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'
apply plugin: 'hugo'
apply plugin: "build-time-tracker"
apply plugin: 'hu.supercluster.paperwork'

paperwork {
    set = [
            gitInfo:   gitInfo(),
            gitSha:    gitSha(),
            buildTime: buildTime("yyyy-MM-dd HH:mm:ss", "GMT+01:00")
    ]
}

def versionMajor = 1
def versionMinor = 2
def versionPatch = 0

android {
    compileSdkVersion androidCompileSdkVersion
    buildToolsVersion androidBuildToolsVersion

    defaultConfig {
        applicationId 'hu.supercluster.gameoflife'
        minSdkVersion androidMinSdkVersion
        targetSdkVersion androidTargetSdkVersion

        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"

        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

    signingConfigs {
        alpha {}
        beta {}
        release {}
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            resValue "string", "app_name_for_buildtype", "Game of Life (debug)"
            minifyEnabled false
            testCoverageEnabled = false
        }

        alpha {
            applicationIdSuffix ".alpha"
            versionNameSuffix "-alpha"
            resValue "string", "app_name_for_buildtype", "Game of Life (alpha)"
            minifyEnabled false
            testCoverageEnabled = false
            lintOptions {
                disable 'MissingTranslation'
            }
        }

        beta {
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
            resValue "string", "app_name_for_buildtype", "Game of Life (beta)"
            minifyEnabled false
            testCoverageEnabled = false
        }

        release {
            resValue "string", "app_name_for_buildtype", "Game of Life"
            minifyEnabled false
            proguardFile 'proguard-project.txt'
        }
    }

    sourceSets.main {
        // src/gen is the target for generated content like json model
        java.srcDirs += 'build/generated/source/db'
    }

    // avoid errors with message 'Duplicate files copied in APK ...'
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}

afterEvaluate {
    def propsFile = rootProject.file('keystore.properties')
    def configName = 'release'

    if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) {
        def props = new Properties()
        props.load(new FileInputStream(propsFile))
        android.signingConfigs[configName].storeFile = rootProject.file(props['storeFile'])
        android.signingConfigs[configName].storePassword = props['storePassword']
        android.signingConfigs[configName].keyAlias = props['keyAlias']
        android.signingConfigs[configName].keyPassword = props['keyPassword']
    }
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}


dependencies {
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:support-annotations:24.2.0'
    compile 'com.android.support:support-v13:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'

    // ---------

    compile 'com.github.tslamic.adn:library:1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true }
    compile 'com.jakewharton.timber:timber:2.5.1'
    compile 'com.squareup:otto:1.3.6'
    compile 'hu.supercluster:paperwork:1.2.7'

    // ---------

    apt "org.androidannotations:androidannotations:" + androidAnnotationsVersion
    compile("org.androidannotations:androidannotations-api:" + androidAnnotationsAPIVersion )

    testCompile 'junit:junit:4.11'
    testCompile 'org.mockito:mockito-core:1.9.5'
    testCompile('com.squareup:fest-android:1.0.+') { exclude module: 'support-v4' }
    testCompile "org.robolectric:robolectric:3.0"

    androidTestCompile 'com.google.guava:guava:14.0.1',
            'com.squareup.dagger:dagger:1.1.0',
            'org.hamcrest:hamcrest-integration:1.1',
            'org.hamcrest:hamcrest-core:1.1',
            'org.hamcrest:hamcrest-library:1.1',
            'com.jakewharton.espresso:espresso:1.1-r3'
}

apt {
    arguments {
        resourcePackageName android.defaultConfig.applicationId
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
    }
}

apply plugin: 'idea'

idea {
    module {
        //and some extra test source dirs
        testSourceDirs += file('src/test')
    }
}

apply from: 'build-time-tracker.gradle'

1 个答案:

答案 0 :(得分:1)

您可以使用--stacktrace运行以获得完整的异常堆栈跟踪

Gradle具有public API和private API的概念。基本上org.gradle.internal中的任何内容都是私有API的一部分,并且gradle团队可以在gradle版本之间更改/删除这些类。理想情况下,插件永远不应引用internal类。任何引用internal API的插件作者必须明白此代码可能会破坏Gradle的新版本。

看起来您的某个插件引用了internal API(org.gradle.internal.TrueTimeProvider),并且该插件是针对一个版本的Gradle构建的,并且您使用的是另一个版本的gradle。

要修复,您需要确定哪个插件正在抛出异常(--stacktrace将在此处提供帮助)。然后,您需要将插件版本更改为与您的gradle版本兼容的版本,或更改您正在运行的gradle版本。