Kickflip / kickflip-android-sdk

Kickflip Android SDK - Live Video Streaming to the Cloud
https://kickflip.io
Apache License 2.0
658 stars 212 forks source link

Multiple dex files defined error when adding apache commons dependencies. #6

Closed silverscania closed 9 years ago

silverscania commented 10 years ago

I know this isn't strictly related to kickflip but it's a pretty annoying problem...

My project depends on apache commons codec and I have

compile 'commons-codec:commons-codec:1.8'

in my build.gradle.

Kickflip is dependant on an AWS jar rather than a maven repo, and the jar also has commons codec. This means that gradle can't detect that my commons codec and the amazon one are the same and it gives:

com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/codec/binary/Base64;

If AWS was added as a proper dependency then it would work. Unfortunately there isn't the android one on maven central. I tried a ton of things to work around this but got nowhere. I tired adding AWS as a submodule and making it a gradle project, removing the apache commons .class file in the kickflip jar etc.

I made a stack overflow question too: http://stackoverflow.com/questions/23677459/excluding-class-files-from-gradle-dependecy

I'm new to gradle, is there anything that can be added to my build.gradle to ignore this second .class file?

Thanks

OnlyInAmerica commented 10 years ago

Excellent point!

I've asked around about this, and feel the current best solution might be to fork aws-sdk-android, convert it to a gradle project, and include that as a submodule dependency. This is a minimal change to aws-sdk-android since it's already configured as a maven project.

In fact this might work right off the bat.

Once we do that you should be able to exclude the apache dep from your project and simply depend on AWS. Or if they're using an old version of commons-codec you could exclude aws's commons-codec:

compile('com.amazonaws:android-sdk-core:1.7.0') {
     // Excluding a particular transitive dependency:
     exclude group: 'commons-codec'
 }

I'm working on it. In the meantime see if that guy's aws-android-sdk-mvn-repo works in place of the aws jars!

silverscania commented 10 years ago

I think the gradle fork is the simplest way, but definitely not the cleanest.

I tried https://github.com/bsphere/aws-android-sdk-mvn-repo without success. It seems to just use pre compiled jars in the same way as kickflip. Looking through the git repo again it doesn't seem right. Although I may have made a mistake.

Anyway, I removed my commons codec dependency in my project. So its not urgent for me at least. I just wanted to learn a bit about gradle.

I wonder if there will ever be an android AWS on maven?

OnlyInAmerica commented 10 years ago

Filed an issue with Amazon Re: Publishing to Maven / Providing Gradle buildscript

OnlyInAmerica commented 9 years ago

we're now using the aws maven artifact so dependency resolution issues like these should no longer be an issue. Feel free to re-open if you experience any other conflicts.