Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase不在我的android项目上工作_Android_Firebase_Firebase Cloud Messaging_Onesignal_Firebase Crash Reporting - Fatal编程技术网

Firebase不在我的android项目上工作

Firebase不在我的android项目上工作,android,firebase,firebase-cloud-messaging,onesignal,firebase-crash-reporting,Android,Firebase,Firebase Cloud Messaging,Onesignal,Firebase Crash Reporting,我正试图在一个Android项目上使用Firebase崩溃报告和通知,我是在工作场所从前任继承下来的 由于一些未知的原因,Firebase或OneSignal拒绝在该项目上工作,应用程序是否在后台并不重要。我使用Android Studio Assistant实现了Firebase 然而,如果我创建新的项目并实现Firebase或OneSignal,那么它的工作效率就会很低 模块构建。渐变 apply plugin: 'com.android.application' android {

我正试图在一个Android项目上使用Firebase崩溃报告和通知,我是在工作场所从前任继承下来的

由于一些未知的原因,Firebase或OneSignal拒绝在该项目上工作,应用程序是否在后台并不重要。我使用Android Studio Assistant实现了Firebase

然而,如果我创建新的项目并实现Firebase或OneSignal,那么它的工作效率就会很低

模块构建。渐变

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'


    defaultConfig {
        applicationId "com.myfirm.appname"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.facebook.android:facebook-android-sdk:4.20.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    compile 'com.android.support:design:25.3.0'
    compile 'com.android.support:customtabs:25.3.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:cardview-v7:25.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    compile 'com.onesignal:OneSignal:3.4.3'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    testCompile 'junit:junit:4.12'
}


apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
项目构建。梯度

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'


    defaultConfig {
        applicationId "com.myfirm.appname"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.facebook.android:facebook-android-sdk:4.20.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    compile 'com.android.support:design:25.3.0'
    compile 'com.android.support:customtabs:25.3.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:cardview-v7:25.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    compile 'com.onesignal:OneSignal:3.4.3'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    testCompile 'junit:junit:4.12'
}


apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.myfirm.appname">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/notification_icon"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:node="replace">

        <service
            android:name=".services.TokenService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <meta-data android:name="onesignal_app_id" android:value="@string/onesignal_app_id" tools:replace="android:value"/>
        <meta-data android:name="onesignal_google_project_number" android:value="@string/onesignal_google_project_number" tools:replace="android:value"/>

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_appid" />


        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="fbXXXXXXXXXXXX" />
            </intent-filter>
        </activity>

        // More Activities
    </application>

</manifest>
需要注意的几点:

  • 当我发送通知时,应用程序总是在后台(我启动了它并按下了home按钮)

  • 在仪表盘(Firebase和OneSignal)上,消息表示已成功发送

  • 我正在Firebase上获取设备令牌,并使用它发送通知。有时它说通知已经发送,有时它说令牌没有注册

  • 看起来我同时使用Firebase和OneSignal的原因是因为我先尝试了Firebase,但没有成功。然后我用了一个信号,希望它能工作,但它没有。因此,如果其中一个有效,我将移除另一个

  • ProjectName>app中存在
    googleservices.json
    ,是的,包名与清单中的包名相对应

  • 即使应用程序分别崩溃,Firebase dashboard上也不会显示崩溃报告


  • 也许你犯了什么错误?失败的原因可能有很多。您是否在firebase控制台中更新了SHA证书指纹,然后在应用程序中重新导入了google-services.json?从logcat?我没有收到任何错误。@Ozuf您看到我上面的评论了吗?