phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.32k stars 996 forks source link

android-support-v13.jar and android-support-v4.jar in the same project #492

Open fernandopg opened 9 years ago

fernandopg commented 9 years ago

Hi I'm using PushPlugin for Android and Facebook SDK for Android in the same project and when I try to Run the app I get the following error:

Error:Execution failed for task ':dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/myuser/Library/Android/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Users/myuser/projects/notorious.client/platforms/android/build/intermediates/dex/debug --input-list=/Users/myuser/projects/notorious.client/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/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs; 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)

I searched about this bug: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs; and seems that is because I have two versions of the android-support lib. And in fact I have android-support-v13.jar (used by PushPlugin) and android-support-v4.jar (used by Facebook SDK).

How can I solve this problem and use both plugins?

Thanks in advance!

I'm using Android Studio 1.0.2, ANDROID_BUILD_TARGET_SDK_VERSION=21 ANDROID_BUILD_MIN_SDK_VERSION=14 ANDROID_BUILD_TOOLS_VERSION=21.1.2 ANDROID_BUILD_SDK_VERSION=21

Rautec commented 9 years ago

same problem here

larswiwi commented 9 years ago

Same problem here, anyone found a solution yet?

fernandopg commented 9 years ago

Hi @larswiwi and @Rautec!

I simply deleted that library from PushPlugin (android-support-v13.jar) and all is working! That worked for me!

Rautec commented 9 years ago

Hi @larswiwi.

We replaced the android-support-v4.jar from the facebook lib by the android-support-v13.jar as it is more actual then the v4 version.

So the steps we did (not sure if everything is necessary).

This steps worked for us.

deliverymanager commented 9 years ago

Thank you very much for the help! I been struggling for a couple of days on this one. Also I got help from this https://github.com/driftyco/ionic-cli/issues/182

uofmmike commented 9 years ago

Howdy all, i've forked an done the changes that @Rautec mentioned. (thanks for the great ideas guys) https://github.com/uofmmike/phonegap-facebook-plugin

Changes to be committed: modified: AndroidManifest.xml modified: build.gradle new file: libs/android-support-v13.jar (stolen from push plugin) deleted: libs/android-support-v4.jar modified: project.properties

https://github.com/uofmmike/phonegap-facebook-plugin/commit/dc1f660aefc44dace7bb1af76b48752c26e91f81

And here's a copy of push without the line mentioned https://github.com/uofmmike/PushPlugin

(No need for all of us to redo all the work!)

\ I have no idea the overall impact, but this is working for me right now

aaguzman commented 9 years ago

I am currently having the same problem. I followed @uofmmike and @Rautec instructions, but now I am getting the error:

Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library

I feel like I am forgetting something simple but I have been trying to fix this problem for last couple days.

uofmmike commented 9 years ago

Verify your config.xml version main android manifest.xml and your androidManifest.xml in the Facebook folder are set to the right minSdkVersion. (Look for a 10 and raise it to a 14)

armno commented 9 years ago

@uofmmike thanks a lot man! your forks work well. :+1:

programming-kid commented 9 years ago

there is this same issue with https://github.com/phonegap/phonegap-plugin-barcodescanner plugin

aq1 commented 9 years ago

Same with https://github.com/luxflux/ionic-hello-world/tree/master/plugins/de.appplant.cordova.plugin.local-notification

kanduvisla commented 9 years ago

Thanks! The problem seems to be when you use the push notification plugin as well as the local notification plugin. Deleting android-support-v4.jar from platforms/android/libs solved this problem for me!

felipepastor commented 8 years ago

Yeap, i've needed to delete android-support-v4.jar from platforms/android/libs to work well. Thanks @kanduvisla

uofmmike commented 8 years ago

i've come across this:

http://stackoverflow.com/questions/21102598/android-studio-unexpected-top-level-exception

Winning Answer (could be of help here)

Like everyone else said here, the support library (com.android.support) is being included more than once in your project. Try adding this in your build.gradle at the root level and it should exclude the support library from being exported via other project dependencies.

root level build.gradle:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
anuragranjan242 commented 8 years ago

simple comment the "cordova.system.library.1=com.android.support:support-v4:+" this line in project.properties file

TzipporahWitty commented 8 years ago

I got this error when I had not yet removed the old phonegap.plugins.PushPlugin from my project. Removed that and it was fine.

raydelto commented 8 years ago

I've removed the oldest android-support jar and I've substituted it with the latest one.

In my case the conflicting plugins were FaceBook connect and PushPlugin

After performing the following command the problem was fixed.

cp ../../code/plugins/com.phonegap.plugins.PushPlugin/src/android/com/plugin/android-support-v13.jar ../../code/platforms/android/phonegap-facebook-plugin/libs/

srinathvsp commented 8 years ago

i got same error after removing one library its working fine

syrakozz commented 8 years ago

how to exclude if i using phonegap build