android gradle插件版本3.3和OneSignal

时间:2019-02-09 18:04:11

标签: android android-gradle repository build.gradle onesignal

当我更新Gradle 4.6 -> 4.10.1Android Gradle plugin 3.2.1 -> 3.3.1时,出现以下错误:

  

错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖关系:无法解析com.google.firebase:firebase-messaging:[10.2.1,12.1.0)。   显示详细资料   受影响的模块:应用

     

错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖关系:无法解析com.android.support:support-v4:[26.0.0,27.2.0)。   显示详细资料   受影响的模块:应用

     

错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖关系:无法解析com.android.support:customtabs:[26.0.0,27.2.0)。   显示详细资料   受影响的模块:应用

     

错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖关系:无法解析com.google.android.gms:play-services-location:[10.2.1,12.1.0)。   显示详细资料   受影响的模块:应用

     

错误:无法解析':app @ releaseUnitTest / compileClasspath'的依赖关系:无法解析com.google.android.gms:play-services-base:[10.2.1,12.1.0)。   显示详细资料   受影响的模块:应用

在检查相关性时,我发现OneSignal implementation 'com.onesignal:OneSignal:3.10.6'抛出了以上错误,例如。

> Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
     Required by:
         project :app > com.onesignal:OneSignal:3.10.6
      > Failed to list versions for com.google.android.gms:play-services-location.
         > Unable to load Maven meta-data from https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk/com/google/android/gms/play-services-location/maven-metadata.xml.
            > Could not get resource 'https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk/com/google/android/gms/play-services-location/maven-metadata.xml'.

现在使用https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk来获取JustPay integration所需的依赖项。

问题 解决以上依赖项来编译项目时,为什么使用错误的存储库?我是在做错什么还是在gradle 3.3中发生了什么变化而导致了此问题?还是gradle 3.3.1的问题?

解决方案:排除此库确实可以解决问题。

implementation ('com.onesignal:OneSignal:3.10.6') {
     exclude group : 'com.google.android.gms'
     exclude group : 'com.android.support'
     exclude group : 'com.google.firebase'
}

我不确定,虽然可能会产生不利影响(如果有请告诉我)。但是,我想找到问题的根源,我想知道为什么这仅发生在Android Gradle插件3.3.1上,而对于Android Gradle插件3.2.1 i.e. without excluding this dependancies也是如此。

这是我的app / build.gradle文件

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath "io.fabric.tools:gradle:$rootProject.fabricGradle"
    }

    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }

    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply plugin: 'project-report'

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url 'https://maven.google.com'
    }
    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
    maven {
        url 'https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk'
    }
    maven {
        url 'https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/'
    }
}

android {
....
....
}

dependencies {
...
implementation 'com.onesignal:OneSignal:3.10.6'
...
}

build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "io.realm:realm-gradle-plugin:5.8.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }
}

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

ext {
...
}

更新:我知道它与3.3中引入的改进的类路径同步有关,但仍然不知道为什么要尝试使用错误的存储库来解决那些依赖关系。

更新2 我也尝试过追踪

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

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

dependencies {
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]' //as well ) at the end
}

1 个答案:

答案 0 :(得分:0)

您可以尝试一下吗?
转到File -> Settings -> Build, Execution, Deployment -> Gradle ->

还有uncheck“离线工作”选项。


更新

删除下面的代码行

classpath 'com.google.gms:google-services:4.2.0'

从顶级build.gradle文件同步开始,并进行一次检查。