Gradle build failing for Android Studio without an

2019-08-19 01:24发布

问题:

I am facing a strange issue. The same code base was working few days ago but today breaking with below error.

Could not find matching constructor for: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.VersionInfo(String)

I am not able to find the reason behind this error. It would be really helpful if any of you can help.

Please find below are the required informations.

dependencies:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation "com.android.support:appcompat-v7:${rootProject.ext.appCompatVersion}"
    implementation "com.crashlytics.sdk.android:crashlytics:${rootProject.ext.crashlyticsVersion}"
    implementation "com.android.support:design:${rootProject.ext.appCompatVersion}"
    implementation "com.android.support.constraint:constraint-layout:${rootProject.ext.constraintLayoutVersion}"
    implementation "com.android.support:recyclerview-v7:${rootProject.ext.appCompatVersion}"
    implementation "com.android.support:cardview-v7:${rootProject.ext.appCompatVersion}"
    implementation "com.onesignal:OneSignal:${rootProject.ext.onesignalVersion}"
    implementation "com.flaviofaria:kenburnsview:${rootProject.ext.kenburnsViewVersion}"
    implementation "com.firebase:firebase-jobdispatcher:${rootProject.ext.firebaseJobDispatcherVersion}"
    implementation "com.github.bumptech.glide:glide:${rootProject.ext.glideVersion}"

    //google admob
    implementation 'com.google.android.gms:play-services-ads:18.0.0'
    implementation 'com.google.firebase:firebase-messaging:+'
    implementation 'com.android.billingclient:billing:1.1'
    implementation "android.arch.persistence.room:runtime:${rootProject.ext.room_version}"
    annotationProcessor "android.arch.persistence.room:compiler:${rootProject.ext.room_version}"
    implementation "android.arch.lifecycle:livedata:${rootProject.ext.lifecycle_version}"
    annotationProcessor "android.arch.lifecycle:compiler:${rootProject.ext.lifecycle_version}"

    //below is for app tutor view
    implementation "com.github.amlcurran.showcaseview:library:${rootProject.ext.showcaseViewVersion}"

    //below two dependencies are for circular image transformation to gif by glide
    implementation "jp.wasabeef:glide-transformations:${rootProject.ext.glideTransformationsVersion}"
    implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'

    //below dependency is for bookmark star animation
    implementation "com.github.varunest:sparkbutton:${rootProject.ext.sparkButtonVersion}"

    //below dependency is for button with validation animation
    implementation "com.unstoppable:submitbutton:${rootProject.ext.submitButtonVersion}"

    //dependency for firebase auth
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.api-client:google-api-client:1.22.0'
    implementation 'com.google.api-client:google-api-client-android:1.22.0'
    implementation 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'

    //dependency for firebase db
    implementation 'com.google.firebase:firebase-database:16.0.2'

    //for signin button google custom
    implementation "com.shobhitpuri.custombuttons:google-signin:${rootProject.ext.googleSigninButtonVersion}"

    //youtube
    implementation files('libs/YouTubeAndroidPlayerApi.jar')

    //support
    implementation "com.android.support:design:${rootProject.ext.appCompatVersion}"

    //webview
    implementation "com.thefinestartist:finestwebview:${rootProject.ext.fineWebviewVersion}"

    //speech to text module
    implementation project(path: ':speech-to-text', configuration: 'default')

    //viewmodel and livedata
    implementation "android.arch.lifecycle:extensions:${rootProject.ext.lifecycle_version}"
    androidTestImplementation 'junit:junit:4.12'

    //memory leaks detection
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'

    // Optional, if you use support library fragments:
    debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
    implementation 'com.android.support:multidex:1.0.3'

    //lottie
    implementation 'com.airbnb.android:lottie:2.5.0'
}

Versions:

ext {
    compileSdkVersion=28
    minSdkVersion=19
    targetSdkVersion=28
    materialDesignVersion='1.0.0'
    appCompatVersion='28.0.0'
    crashlyticsVersion='2.9.9'
    constraintLayoutVersion='1.1.3'
    onesignalVersion='3.9.1'
    glideVersion='4.9.0'
    firebaseJobDispatcherVersion='0.8.5'
    kenburnsViewVersion='1.0.6'
    room_version='1.1.1'
    lifecycle_version='1.1.1'
    fineWebviewVersion='1.2.7'
    showcaseViewVersion='5.4.3'
    glideTransformationsVersion='3.3.0'
    sparkButtonVersion='1.0.5'
    submitButtonVersion='1.1.3'
    googleSigninButtonVersion='1.0.0'
    lifecycle_version="1.1.1"
}

I am using Gradle version of 3.4.1 I tried clean project, rebuild project, invalidate cache and restart. None of it helped.

P.S: I have looked into this question already and I am using OneSignal and I need it.

回答1:

It seems that OneSignal plugin is using internal gradle APIs (VersionInfo is under the org.gradle.api.internal package). Unlike the public Gradle APIs, the Gradle team can change internal APIs without warning and make no guarantees that they won't have breaking changes between Gradle versions.

Perhaps you're on an old version of the OneSignal plugin which is now broken with your newer version of Gradle. Perhaps there's a newer version of the plugin which will work?

Failing that you could track down the plugin author and submit a bug to the project, or perhaps submit a pull request with a fix



回答2:

I was able to fix it finally. Below is the fix I found after contacting OneSignal support.

Cause: Changes from OneSignal affected it.

Fix: 1. The way we implement OneSignal SDK has been changed and it was not notified to the users. Earlier, below was the first step of implementation.

plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
maven { url 'https://maven.google.com' }
}

Now, you need to change it to

buildscript {
repositories {
    maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.2'
}
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
maven { url 'https://maven.google.com' }
}

Making above will fix the error. However, I had to then migrate my project to androidX too. so, 2. Migrate project to androidX.

above two steps fixed the bug.