Problem

I'm building an Android app using Cordova 5.3.3 (latest), and using the pushwoosh cordova plugin for push notifications ( https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin ).

The app also uses the facebook-connect plugin ( https://github.com/Wizcorp/phonegap-facebook-plugin )

The pushwoosh plugin seems to conflict with the facebook connect plugin. When the two plugins are added to a new cordova project, the application build starts failing. This is the message:

:compileDebugJava
:preDexDebug
:dexDebug

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/shishir.srivastava/Development/android-sdk-macosx/build-tools/22.0.1/dx --dex --no-optimize --output /Users/shishir.srivastava/Shishir/MallMate/Code/MallMateCordova-temp/platforms/android/build/intermediates/dex/debug --input-list=/Users/shishir.srivastava/Shishir/MallMate/Code/MallMateCordova-temp/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
    2
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Fix

To fix the above issue, I added the following to build-extras.gradle file in the android folder.

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

This allowed the app to build without any issues. However, now, the app crashes when pushNotification.registerDevice() is called.

I used adb shell logcat to check the error logs, and saw this:

D/PushNotifications( 4751): Plugin Called
D/Pushwoosh( 4751): broadcastPush = true
I/Pushwoosh( 4751): Log level: NOISE
V/Pushwoosh( 4751): [RegistrationPrefs] Saving regId on app version 178
I/Pushwoosh( 4751): [PushManager] App ID: #####-#####
I/Pushwoosh( 4751): [PushManager] Project ID: 1088448295557
I/Pushwoosh( 4751): [PushManager] This is android device
W/ActivityManager(  943): Unable to start service Intent { cmp=com.shishir/com.pushwoosh.inapp.InAppRetrieverService } U=0: not found
V/Pushwoosh( 4751): [PushRegistrarGCM] number of receivers for com.shishir: 3
V/Pushwoosh( 4751): [PushRegistrarGCM] Found 1 receivers for action com.google.android.c2dm.intent.RECEIVE
W/Pushwoosh( 4751): [RequestManager] Try To sent: registerUser
W/PluginManager( 4751): THREAD WARNING: exec() call to PushNotification.onDeviceReady blocked the main thread for 61ms. Plugin should use CordovaInterface.getThreadPool().
I/chromium( 4751): [INFO:CONSOLE(1)] "pushwoosh initialized", source: file:///android_asset/www/app.js (1)
D/PushNotifications( 4751): Plugin Called
W/Pushwoosh( 4751): [RequestManager] Pushwoosh Request: {"request":{"v":"3.1.8.563","device_type":3,"application":"#####-#####","hwid":"###","userId":"###"}}
W/Pushwoosh( 4751): [RequestManager] Pushwoosh Request To: https://cp.pushwoosh.com/json/1.3/registerUser
V/Pushwoosh( 4751): [com.pushwoosh.GCMRegistrationService] Intent action = com.pushwoosh.gcm.intent.REGISTER
I/chromium( 4751): [INFO:CONSOLE(1)] "pushwoosh: post registration", source: file:///android_asset/www/app.js (1)
W/cr.BindingManager( 4751): Cannot call determinedVisibility() - never saw a connection for the pid: 4751
I/chromium( 4751): [INFO:CONSOLE(1)] "[object Object]", source: file:///android_asset/www/app.js (1)
E/AndroidRuntime( 4751): FATAL EXCEPTION: IntentService[com.pushwoosh.GCMRegistrationService]
E/AndroidRuntime( 4751): Process: com.shishir, PID: 4751
E/AndroidRuntime( 4751): java.lang.NoSuchMethodError: No virtual method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.shishir-1/base.apk)
E/AndroidRuntime( 4751):    at com.google.android.gms.iid.zzd.zzdo(Unknown Source)
E/AndroidRuntime( 4751):    at com.google.android.gms.iid.zzd.<init>(Unknown Source)
E/AndroidRuntime( 4751):    at com.google.android.gms.iid.zzd.<init>(Unknown Source)
E/AndroidRuntime( 4751):    at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
E/AndroidRuntime( 4751):    at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
E/AndroidRuntime( 4751):    at com.pushwoosh.GCMRegistrationService.register(Unknown Source)
E/AndroidRuntime( 4751):    at com.pushwoosh.GCMRegistrationService.onHandleIntent(Unknown Source)
E/AndroidRuntime( 4751):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/AndroidRuntime( 4751):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 4751):    at android.os.Looper.loop(Looper.java:211)
E/AndroidRuntime( 4751):    at android.os.HandlerThread.run(HandlerThread.java:61)
D/ActivityManager(  943): New dropbox entry: com.shishir, data_app_crash, ####
W/ActivityManager(  943):   Force finishing activity 1 com.shishir/.MainActivity

From what I understand, this seems to be the mail reason behind the crash:

java.lang.NoSuchMethodError: No virtual method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.shishir-1/base.apk)

I'm a little lost as to how I should proceed from here. Any help will be greatly appreciated.

Thank you!

asked 06 Oct '15, 17:28
Shishir's gravatar image

Shishir
2114

I realised that the facebook connect plugin that I was using was using an outdated version of FB SDK. I switched to this one, and the problem was resolved: https://github.com/jeduan/cordova-plugin-facebook4

permanent link
answered 08 Oct '15, 18:26
Shishir's gravatar image

Shishir
2114

Hi friend. I'm having the same issue. It's my first time using PushWoosh and i've seen a lot of questions about Push plugins and Facebook connect.

I looked for your Fix but i can't find build-extras.gradle on my android folder.

:/ I need help too.

================================

Edit: I Googled about this :D i did the same trick that you did, and having same problem.

+1

permanent link
answered 07 Oct '15, 19:27
menugastronomico's gravatar image

menugastrono...
11

edited 07 Oct '15, 19:33

1

Hey. You need to create a new file called "build-extras.gradle" in the "platforms/android" folder, and add the fix.

(07 Oct '15, 19:29) Shishir Shishir's gravatar image

Oh man, sorry. I didn't get the same error as you. I'm following the example on github but my pushwoosh is not updating with a new device. My app is opening and working fine but i can't send a push and pushwoosh is not recognizing my app.

Maybe i'm having a problem with starting the plugin on my code i think. I will try again and if i get the same error as you i wiill reply.

(07 Oct '15, 20:09) menugastrono... menugastronomico's gravatar image

Hello,

I have done same.I have created new file and code still app crash.Can Please help me

(11 Jan '16, 12:02) mayurloved mayurloved's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×326
×190
×76
×30

question asked: 06 Oct '15, 17:28

question was seen: 2,648 times

last updated: 11 Jan '16, 12:02