OneSignal / OneSignal-Gradle-Plugin

Use with OneSignal-Android-SDK to help integrate it into your Android Studio or Gradle project. https://onesignal.com
Other
64 stars 17 forks source link

Could not resolve gradle.plugin.com.onesignal:onesignal-gradle-plugin #168

Closed noorbakerally closed 3 years ago

noorbakerally commented 3 years ago

Since yesterday night, I am getting the problem below with a flutter project. The issue is that I did not change anything so I have no idea what to rollback.

Project Setup

build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        maven {
            url 'http://storage.googleapis.com/r8-releases/raw'
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:2.1.75'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

buildscript {
    repositories {
        // ...
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        // ...
        // OneSignal-Gradle-Plugin
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
}

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

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.inspireui.fluxstore"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "en"
    }

    signingConfigs {
        release {

            if (System.getenv()["CI"]) { // CI=true is exported by Codemagic
                storeFile file(System.getenv()["FCI_BUILD_DIR"] + "/key.jks")
                storePassword System.getenv()["FCI_KEYSTORE_PASSWORD"]
                keyAlias System.getenv()["FCI_KEY_ALIAS"]
                keyPassword System.getenv()["FCI_KEY_PASSWORD"]
            } else {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }
    }

    buildTypes {
        release {
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.android.support:multidex:1.0.3'

    // For checking GMS availability.
    implementation "com.google.android.gms:play-services-base:17.6.0"
}
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = true }

//Fix android-r issue
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
    afterEvaluate {project ->
        if (project.hasProperty("android") && project.property("android").compileSdkVersion.equals("android-R")) {
            android {
                compileSdkVersion 30
            }
        }
    }
}

Full Error

Launching lib/main.dart on INE LX1r in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* Where:
Build file '/home/noor/Documents/SMS/Development/V2/codecanyon-aYr63xj3-fluxstore-woocommerce-flutter-ecommerce-full-app/android/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not resolve all artifacts for configuration ':app:classpath'.
      > Could not resolve gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99].
        Required by:
            project :app
         > No matching variant of gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.2 was found. The consumer was configured to find a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally but:
             - Variant 'apiElements' capability gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.2 declares a component, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
             - Variant 'runtimeElements' capability gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.2 declares a runtime of a component, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 520ms
Exception: Gradle task assembleDebug failed with exit code 1

Dependency Tree Cannot put dependency tree here, too long, i placed it in a google doc, here is the link

jkasten2 commented 3 years ago

@noorbakerally Thanks for reporting. This was fixed in version 0.13.3. However version 0.13.4 needs to be used to fully run with Java 8.