Urban-airship + Facebook cordova plugin android-support-v4 conflict

482 views Asked by At

I'm tring to use Urban-airship cordova plugin (phonegap-ua-push) along with Facebook plugin (phonegap-facebook-plugin) but I facing this error:

Multiple dex files define Landroid/support/annotation/AnimRes

Which seems to be due to a conflic between the facebook android-support-v4 and phonegap-ua-push, as it compile with a different support-v4 version.

dependencies {
 compile 'com.android.support:cardview-v7:22.2.0'
 compile 'com.android.support:support-v4:22.2.0'
 compile 'com.google.android.gms:play-services-location:7.5.0'
 compile 'com.google.android.gms:play-services-gcm:7.5.0'
 compile 'com.urbanairship.android:urbanairship-sdk:6.1.3'
}

I tried to update the phonegap-ua-push's dependencies, and exclude support-v4 that it rely on, hoping that it will be able to work with the Facebook one. Here is how I did that:

dependencies {
  compile ('com.android.support:cardview-v7:22.2.0') {       
    exclude module: 'support-v4'
  }
  compile ('com.google.android.gms:play-services-location:7.5.0') {       
    exclude module: 'support-v4'
  }
  compile ('com.google.android.gms:play-services-gcm:7.5.0') {       
    exclude module: 'support-v4'
  }
  compile ('com.urbanairship.android:urbanairship-sdk:6.1.3') {       
    exclude module: 'support-v4'
  }
}

But when the app receive a push notification, the app crash.. Here is the exception from logcat:

E/AndroidRuntime(24095): java.lang.NoSuchMethodError: No virtual method setColor(I)Landroid/support/v4/app/NotificationCompat$Builder; in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes (declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/com.****.****-1/base.apk)

Does someone have achieved to use both facebook and urbanairship plugins, and how ?

EDIT: As ralepinski said, I tried to remove the android-support-v4.jar from the platforms/android/FacebookLib/libs/ folder , and when I do I've got tones of the following error:

FacebookLib/src/com/facebook/AppEventsLogger.java:24: error: package android.support.v4.content does not exist import android.support.v4.content.LocalBroadcastManager; ...

I think it's tring to tell me that he can't find android-support-v4

Which doesnt make sense to me because the build.gradle of the FacebookLib as the following lines:

dependencies {
    compile 'com.android.support:support-v4:[20,21)'
    compile 'com.parse.bolts:bolts-android:1.1.2'
}

And so should be able to understand that android-support-v4 is needed. I probably miss-understand something here..

I tried as well to replace the android-support-v4 by the one used by phonegap-ua-push, android-support-v4-22.2.0, but it seems there is some missing symbol:

error: cannot find symbol FragmentManagerImpl mFragmentManager;

error: cannot find symbol FragmentManagerImpl mChildFragmentManager;

2

There are 2 answers

0
Thomas On BEST ANSWER

I finally solve my problem, by using this fork https://github.com/jeduan/cordova-plugin-facebook4 of the Facebook plugin, which use the last Facebook sdk.

1
ralepinski On

The Facebook plugin you are using ships an outdated version of the support library. I would file an issue with them. It looks like they might be using gradle anyways, so they just need to remove the support-library.

Since it looks like you have to clone the Facebook plugin, you can try to remove the support library from the plugin - https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/android/FacebookLib/libs/android-support-v4.jar and see if that works for you. If not, try just updating the support library with a newer version and keep your gradle excludes.