gpt4 book ai didi

android - android gradle 插件版本 3.3 和 OneSignal 的问题

转载 作者:行者123 更新时间:2023-11-29 02:22:19 32 4
gpt4 key购买 nike

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

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-v4:[26.0.0, 27.2.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:customtabs:[26.0.0, 27.2.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[10.2.1, 12.1.0). Show Details Affected Modules: app

在检查依赖项时,我发现 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 ,即不排除此依赖项

这是我的 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
}

最佳答案

你能试试这个吗:
转到 File -> Settings -> Build, Execution, Deployment -> Gradle ->

并且取消选中“离线工作”选项。


更新:

删除下面的代码行

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

从顶层build.gradle文件同步并检查一次。

关于android - android gradle 插件版本 3.3 和 OneSignal 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54609074/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com