react-native-push-notification dependency stops application

Created on 26 Oct 2016  路  14Comments  路  Source: zo0r/react-native-push-notification

Hi,
I'm trying to create a react-native app which needs to display some notifications. All worked fine until I've added react-native-push-notification dependency. Now as you can see in attached screenshot, application fails to start.
image

Following are project dependecies:

dependencies {
    compile project(':react-native-push-notification')
    compile project(':react-native-video')
    compile project(':react-native-vector-icons')
    compile project(':react-native-permissions')
    compile project(':react-native-maps')
    compile project(':react-native-image-picker')
    compile project(':react-native-geocoder')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile ('com.google.android.gms:play-services-gcm:9.+') {
        force = true;
    }
}

Can someone please help me to solve this?

Most helpful comment

This is happening because of incompatible v7 and play service libs. (gcm:8.4.0)

My gradle build script was like this:
compile "com.android.support:appcompat-v7:23.0.1" compile ('com.google.android.gms:play-services-gcm:8.4.0') { force = true; }

I changed this to following it worked.

compile "com.android.support:appcompat-v7:23.4.0" compile ('com.google.android.gms:play-services-gcm:9.0.1') { force = true; }

@jeveloper thanks for the tip buddy 馃憤

All 14 comments

You need to look at the android logs to see what's happened. In the mean time just back out the changes you made.

I had this issue as well, adb logcat revealed:

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd'

Not sure what changed, I'm running RN 0.36 and using android build tools v23.0.1

You're missing specific appcompat v4 lib , its not related to tools

@jeveloper I also having same issue.
It worked previously but after updating 'SDK tools and 'SDK flatform tools' got this issue

I tried adding v4 lib to build.gradle file as follows but no luck.

compile 'com.android.support:support-v4:23.0.3'

Having the same issue as abefetterman:

I had this issue as well, adb logcat revealed:

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd'

Using:

"react": "~15.2.1"
"react-native": "0.31.0"
"react-native-push-notification": "2.0.2"

build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
   ...
   defaultConfig {
        applicationId (removed)
        minSdkVersion 16
        targetSdkVersion 22
        versionCode (removed)
        versionName (removed)
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile 'com.facebook.android:facebook-android-sdk:4.15.0'
    compile "com.facebook.react:react-native:+"

    compile project(':react-native-maps')
    compile project(':react-native-vector-icons')
    compile project(':react-native-push-notification')
    compile project(':react-native-google-analytics-bridge')
    compile project(':react-native-fbsdk')
    compile project(':react-native-code-push')
    compile project(':react-native-camera')
    compile project(':react-native-toast')
    compile project(':react-native-share')
    compile project(':react-native-splashscreen')
    compile project(':react-native-image-picker')
    compile project(':RNSendIntentModule')
}

Any help getting the issue resolved will be greatly appreciated.

Folks, google split v7 and v4 into small sub libraries , the naming has changed, so take a look at the respective libraries , especially try to provide a flag to see more stack trace so you you know which lib is missing.
No problems with 2.1.1 (sticking with it ) as 2.2 doesn't seem to find react package at all

I've found this: android - ERROR of 25.0.0 while compiling the project

Essentially, the react-native-fbsdk leaves the facebook-android-sdk version unchecked which broke my dependencies.
compile('com.facebook.android:facebook-android-sdk:4.+')

A temporary fix is to force the facebook-android-sdk version to where it did not reference the newer libraries. (This is not ideal, but works in the interim):

dependencies {
   ...
   compile ('com.facebook.android:facebook-android-sdk:4.16.1') {
       force = true
    }
   ...
}

Whoa @ryno-stackworx , adding an SDK for facebook? but its not even used
I'm telling you, v4 and v7 have been split by google

Here is the resource:

https://developer.android.com/topic/libraries/support-library/features.html

here is one you might try:

com.android.support:support-compat:25.0.0

Make sure you have the support libs installed locally (via studio)

This is happening because of incompatible v7 and play service libs. (gcm:8.4.0)

My gradle build script was like this:
compile "com.android.support:appcompat-v7:23.0.1" compile ('com.google.android.gms:play-services-gcm:8.4.0') { force = true; }

I changed this to following it worked.

compile "com.android.support:appcompat-v7:23.4.0" compile ('com.google.android.gms:play-services-gcm:9.0.1') { force = true; }

@jeveloper thanks for the tip buddy 馃憤

@jeveloper the facebook SDK is related to other dependencies in my project. So we can safely conclude that my issue isn't specific to react-native-push-notifications

Just so you know I've tried the following(and a lot of others) before but did not solve my issue.

com.android.support:support-compat:25.0.0
com.android.support:appcompat-v7:23.4.0
com.google.android.gms:play-services-gcm:9.0.1

Thanks for clarification

@EmpiteDinesh
Used the same config as u and it worked! thanks!
I was lost! 馃槷

Folks, i think we can close this issue
plenty of good tips here ;)

thanks, this really solve my big problem. almost cry!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kiran0791 picture Kiran0791  路  3Comments

atteia picture atteia  路  4Comments

DanDance picture DanDance  路  3Comments

Benzer1406 picture Benzer1406  路  3Comments

sungjinoh picture sungjinoh  路  3Comments