React-native-push-notification: App crash on startup

Created on 31 Oct 2018  路  16Comments  路  Source: zo0r/react-native-push-notification

927

I have installed react-native-push-notification and in android my project builds but it doesn't start.

Stale

Most helpful comment

I also had the same issue in react-native: 0.57.8. But worked perfect in react-native: 0.58.5. That issue was resolved by adding
googlePlayServicesVersion = "+"
firebaseVersion = "+" in android/build.gradle as mentioned in documentation

All 16 comments

+1 described in: #910

+1

+1

Im getting this issue as well. I have no issues until i add google-maps capabilities to the application.

Before this remote and local notifications work completely as intended. With the addition it crashes immediately.

hi @Vincenzo1997, i am getting same crash report, did you resolve this issue?

I have fixed the issue for me, im not sure if this is of any use to you but my react-native link added the react-native-push-notification files multiple times to my gradle and .java files.

Keep an eye out for this, if you have a commit where you know it worked try running just
react-native link react-native-push-notification only

This worked for me. I realise its specific to my case but hopefully this simple fix helps someone!

I have started to get the same issue after upgrading version to 3.1.2, try to configure again but it just crashes immediately after I build the app. Could not solve the issue

I have removed this lib and just use react-native-firebase

+1

@hoanghaihuy , I have removed "react-native-firebase" and install this library, because "react-native-firebase" require too many changes in native side of project and build requirements, and since that it incompatible with lot of other libraries in my project. So please do not mislead people - "react-native-firebase" is really great project, but it not replacement for this library

@Zaporozhec7 yes, you're right. react-native-firebase cannot replace for this lib. And I just talked about my own solution to solve this problem which have not been solved through bunch of similar issues.

i think i finde my problem,,, im using react-native-maps and react-native-push-notification. in react native project. when i link bouth at sime time my app crash before start. according to documentation https://github.com/zo0r/react-native-push-notification play-service-gcm and firebase-messaging, prior to version 15 requires to have the same version number in order to work correctly at build time and at run time. To use a specific version: i change my build.gradle dependencis in react-native-push-notification. from def firebaseVersion = project.hasProperty('firebaseVersion') ? project.firebaseVersion : DEFAULT_FIREBASE_MESSAGING_VERSION to def firebaseVersion = project.hasProperty('firebaseVersion') ? project.firebaseVersion : '11.8.0' and i add i android/build.gradle googlePlayServicesVersion = "11.8.0", same version

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

allprojects {
repositories {
jcenter()
}
}

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_SUPPORT_LIB_VERSION = "27.1.1"
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

defaultConfig {
    minSdkVersion 16
    targetSdkVersion project.hasProperty('targetSdkVersion') ? project.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
def supportLibVersion = project.hasProperty('supportLibVersion') ? project.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION
def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
def firebaseVersion = project.hasProperty('firebaseVersion') ? project.firebaseVersion : '11.8.0' // DEFAULT_FIREBASE_MESSAGING_VERSION

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile 'com.facebook.react:react-native:+'
compile "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
compile 'me.leolin:ShortcutBadger:1.1.8@aar'
compile "com.google.firebase:firebase-messaging:$firebaseVersion"

}

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

buildscript {
ext {
// firebaseVersion=16
googlePlayServicesVersion = "11.8.0"
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}

I also had the same issue in react-native: 0.57.8. But worked perfect in react-native: 0.58.5. That issue was resolved by adding
googlePlayServicesVersion = "+"
firebaseVersion = "+" in android/build.gradle as mentioned in documentation

I had the same issue, I tried to add these lines :

googlePlayServicesVersion = "+"
firebaseVersion = "+"

But I faced the same problem.
I checked my app/build.gradle to get correct version numbers :

    implementation "com.google.android.gms:play-services-base:16.1.0"
    ...
    implementation "com.google.firebase:firebase-messaging:17.5.0"

I modified the version numbers on android/build.gradle

googlePlayServicesVersion = "16.1.0"
firebaseVersion = "17.5.0"

And my app started :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

lkflkflfkflkf

Was this page helpful?
0 / 5 - 0 ratings