【问题标题】:Onesignal Android SDK ErrorOnesignal Android SDK 错误
【发布时间】:2018-05-21 20:03:41
【问题描述】:

我尝试将 Onesignal 实现到我的 android 项目中,但我遇到了有关 Firebase 的错误:

无法解决:com.google.firebase:firebase-messaging:15.0.1

我在文档中做了所有事情:https://documentation.onesignal.com/docs/android-sdk-setup#section-android-studio

这是我的 build.gradle

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

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

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.my.package"
        manifestPlaceholders = [
                onesignal_app_id: 'XXXXXX-1b8c-48d3-a596-d277fad80edc',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'XXX921710280' ]
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 2
        versionName "v2.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.simbiose:Encryption:2.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.scottyab:aescrypt:0.0.1'
    compile 'com.github.bloder:magic:1.1'
    compile 'com.onesignal:OneSignal:3.9.1'
}

【问题讨论】:

  • 使用classpath google play services version 3.3.1,支持Firebase 15+。

标签: android onesignal


【解决方案1】:

build.gradle 中:

添加:

jcenter()

在你的repositories

然后再次同步Gradle

【讨论】:

  • 我的文件中没有任何 mavenCentral
  • @ChaoukiAnass 你的 android studio 版本是多少?
  • 我的版本是3.1.2
  • @ChaoukiAnass 你在你的 android studio 中检查了Global Gradle sestting 以取消Offline work 吗?
  • @ChaoukiAnass 当然,去File>Settings>Build,Execution,Deployment>Build Tools>Gradle找到Offline work复选框,如果它被选中,取消它。然后再次同步 Gradle
【解决方案2】:

现在可以了,我必须实现相同的版本:

implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'

【讨论】:

    猜你喜欢
    • 2022-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 2015-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多