Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fernandopg opened this issue Feb 17, 2015 · 19 comments
Open

Comments

@fernandopg
Copy link

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
Copy link

Rautec commented Mar 22, 2015

same problem here

@larswiwi
Copy link

larswiwi commented Apr 1, 2015

Same problem here, anyone found a solution yet?

@fernandopg
Copy link
Author

Hi @larswiwi and @Rautec!

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

@Rautec
Copy link

Rautec commented Apr 2, 2015

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).

  • replace android-support-v4.jar by android-support-v13.jar
  • in the phonegap-facebook-plugin/platforms/android/FacebookLib/build.gradle change to compile 'com.android.support:support-v13:[20,21)'
  • in phonegap-facebook-plugin/platforms/android/FacebookLib/project.properties change the target to at least target=android-14
  • in phonegap-facebook-plugin/platforms/android/FacebookLib/AndroidManifest.xml change the minSdkVersion to at least <uses-sdk android:minSdkVersion="14" />

This steps worked for us.

@deliverymanager
Copy link

Thank you very much for the help! I been struggling for a couple of days on this one.
Also I got help from this
ionic-team/ionic-cli#182

@uofmmike
Copy link

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

uofmmike/phonegap-facebook-plugin@dc1f660

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
Copy link

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
Copy link

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
Copy link

armno commented May 18, 2015

@uofmmike thanks a lot man! your forks work well. 👍

@programming-kid
Copy link

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

@kanduvisla
Copy link

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
Copy link

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

@uofmmike
Copy link

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
Copy link

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

@Tzafra
Copy link

Tzafra commented Nov 22, 2015

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
Copy link

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
Copy link

i got same error after removing one library its working fine

@syrakozz
Copy link

how to exclude if i using phonegap build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests