【问题标题】:Project refresh failed - Error:Cause: org/gradle/internal/TrueTimeProvider项目刷新失败 - 错误:原因:org/gradle/internal/TrueTimeProvider
【发布时间】:2017-06-06 13:41:20
【问题描述】:

从 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'

【问题讨论】:

    标签: android android-studio gradle


    【解决方案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 版本。

    【讨论】:

    • 我的目标是让应用程序运行,所以我尝试将自定义位置设置为更新版本的 gradle(3.5 和 4.0rc),但最终给出了相同的结果。将 gradle 的 build.gradle 类路径更改为 3.5.0 而不是 2.3.2 会导致它无法找到该库,即使我已经设置了它。它正在搜索 gradle-3.5.0.jar 并且在 gradle 文件夹中找不到该文件。 Android Monitor 是空的并且没有显示任何消息。感谢您的详尽回答。
    • 只是猜测...但我会尝试注释掉apply plugin: "build-time-tracker"。动态内部版本号也存在问题(例如0.5.+1.+)。使用特定版本会更好
    • 我尝试使用特定版本,但这不是我的项目。注释掉“build-time-tracker”解决了原来的问题。非常感谢。
    • 你很幸运,我可以从类名和插件名中做出有根据的猜测。堆栈跟踪在这里会有所帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-24
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多