No. It seems we're pretty well stuck unless you can repackage the aar 
yourself file and remove jar from the libs folder.

On Saturday, September 27, 2014 3:30:58 PM UTC-5, Parveen Kumar wrote:
>
> Hey John, I am facing the exact same problem. Did you find a solution?
>
> -Parveen
>
> On Friday, September 19, 2014 3:34:35 PM UTC-5, John Frey wrote:
>>
>> So I'm having this same issue right now. Is there no way for a consumer 
>> of an aar library to exclude a transitive dependency buried within the 
>> /libs folder of said library? For example...
>>
>> compile('com.example.mylibrary:1.0') {
>>     exclude module: 'android-support-v4'
>>     exclude module: 'date4j'
>> }
>>
>>
>> This doesn't work if date4j and android-support-v4 are jars inside the 
>> libs folder. 
>>
>> On Wednesday, April 2, 2014 1:56:56 AM UTC-5, Roman Mazur wrote:
>>>
>>> I haven't tried to solve that particular problem, but you can try using 
>>> 'provided' configuration for a local jar file.
>>> I saw complains that local file dependencies from 'provided' 
>>> configuration are still included to aar packages though.
>>>
>>>
>>> On 31 March 2014 23:58, Cheng Yang <[email protected]> wrote:
>>>
>>>> Hi Roman, Have you figure out how to exclude the jar befoer publishing?
>>>>
>>>> On Monday, July 22, 2013 9:45:58 PM UTC-7, Roman Mazur wrote:
>>>>>
>>>>> Yes, this is exactly what I want.
>>>>> But can I exclude a jar in libs folder from my dependencies before 
>>>>> publishing?
>>>>>
>>>>> On Tuesday, 23 July 2013 02:11:29 UTC+3, Xavier Ducrohet wrote:
>>>>>>
>>>>>> The requirement on the library is not declared at runtime in this 
>>>>>> case, so this is different from what I understood.
>>>>>>
>>>>>> In this case you would add flurry as a dependency on your library but 
>>>>>> remove it from the dependencies when publishing the artifact. Then the 
>>>>>> app 
>>>>>> would have to manually include the Flurry library if they want to use it.
>>>>>>
>>>>>>
>>>>>> On Fri, Jul 19, 2013 at 11:02 PM, Roman Mazur <[email protected]> 
>>>>>> wrote:
>>>>>>
>>>>>>> Let's imagine a library that provides some Android activities and 
>>>>>>> can integrate with some statistics services, let it be Flurry to 
>>>>>>> illustrate. But it does so only when the app actually uses that SDK. 
>>>>>>> We cannot get Flurry SDK jar from a repository, so that it must be 
>>>>>>> placed into libs folder of our Android library. But our library does 
>>>>>>> not 
>>>>>>> require this jar to provide its core functionality. But now we cannot 
>>>>>>> use 
>>>>>>> our library without omitting Flurry SDK jar being included to 
>>>>>>> application 
>>>>>>> package.
>>>>>>> I do understand that this library can be divided into two parts, 
>>>>>>> like core and flurry integration. But as for me, going the described 
>>>>>>> way 
>>>>>>> can be useful too.
>>>>>>>
>>>>>>>
>>>>>>> On 19 July 2013 19:26, Xavier Ducrohet <[email protected]> wrote:
>>>>>>>
>>>>>>>> If it's determined at runtime whether the lib is needed or not, 
>>>>>>>> then it's still needed to be packaged in case it's needed at runtime. 
>>>>>>>> am I 
>>>>>>>> missing something?
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jul 9, 2013 at 12:33 AM, Roman Mazur <[email protected]> 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> What if a jar placed in the libs directory is optional and its 
>>>>>>>>> presence is determined in runtime by the library? Is there a way to 
>>>>>>>>> exclude 
>>>>>>>>> it from aar package?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, 24 May 2013 22:26:52 UTC+3, Xavier Ducrohet wrote:
>>>>>>>>>
>>>>>>>>>> This is expected when referencing local jars from library 
>>>>>>>>>> projects. There's no way around it, we need to include it in aar.
>>>>>>>>>>
>>>>>>>>>> I'm working right now to have those in a repository so that you 
>>>>>>>>>> can reference artifact instead which will allow Gradle to resolve 
>>>>>>>>>> the 
>>>>>>>>>> dependencies correctly when building an app using different library 
>>>>>>>>>> projects that all depends on support-v4 or other support libs.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, May 24, 2013 at 12:24 PM, Traun Leyden <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I'm creating a library using this build.gradle:
>>>>>>>>>>>
>>>>>>>>>>> ...
>>>>>>>>>>> repositories {
>>>>>>>>>>>     mavenCentral()
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> dependencies {
>>>>>>>>>>>
>>>>>>>>>>>     compile files('libs/android-support-v4.jar')
>>>>>>>>>>>
>>>>>>>>>>>     instrumentTestCompile 'commons-io:commons-io:2.0.1'
>>>>>>>>>>>
>>>>>>>>>>>     compile 'org.codehaus.jackson:jackson-core-asl:1.9.2'
>>>>>>>>>>>     compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.2'
>>>>>>>>>>>
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> uploadArchives {
>>>>>>>>>>>      repositories {
>>>>>>>>>>>         mavenDeployer {
>>>>>>>>>>>             repository(url: uri("../testrepo"))
>>>>>>>>>>>             ..
>>>>>>>>>>>         }
>>>>>>>>>>>     }
>>>>>>>>>>> }
>>>>>>>>>>> ..
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> and then I'm running "./gradlew :CBLite:uploadArchives", which 
>>>>>>>>>>> causes an .aar to be generated in the local testrepo directory.  
>>>>>>>>>>> When I 
>>>>>>>>>>> unzip the .aar, I can see that it contains lib/ android-support-
>>>>>>>>>>> v4.jar.
>>>>>>>>>>>
>>>>>>>>>>> The problems start when I try to use the generated .aar as a 
>>>>>>>>>>> dependency in another project.  Here's the build.gradle from the 
>>>>>>>>>>> project 
>>>>>>>>>>> which consumes this dependency:
>>>>>>>>>>>
>>>>>>>>>>> ...
>>>>>>>>>>> repositories {
>>>>>>>>>>>     mavenCentral()
>>>>>>>>>>>     maven {
>>>>>>>>>>>         url "file:///../couchbase-lite-and
>>>>>>>>>>> roid/CouchbaseLiteProject/testrepo"
>>>>>>>>>>>     }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> dependencies {
>>>>>>>>>>>     compile files('libs/android-support-v4.jar')
>>>>>>>>>>>     compile 'com.couchbase.cblite:CBLite:1.0'
>>>>>>>>>>> }
>>>>>>>>>>> ...
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> when I try to build the project with "./gradlew assemble", I get 
>>>>>>>>>>> this error:
>>>>>>>>>>>
>>>>>>>>>>> :HelloCBLite:dexDebug
>>>>>>>>>>>
>>>>>>>>>>> UNEXPECTED TOP-LEVEL EXCEPTION:
>>>>>>>>>>> java.lang.IllegalArgumentException: already added: 
>>>>>>>>>>> Landroid/support/v4/app/ActivityCompatHoneycomb;
>>>>>>>>>>>  at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSectio
>>>>>>>>>>> n.java:123)
>>>>>>>>>>> at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
>>>>>>>>>>>  at com.android.dx.command.dexer.Main.processClass(Main.java:490
>>>>>>>>>>> )
>>>>>>>>>>> at com.android.dx.command.dexer.Main.processFileBytes(Main.java
>>>>>>>>>>> :459)
>>>>>>>>>>>  at com.android.dx.command.dexer.Main.access$400(Main.java:67)
>>>>>>>>>>> at com.android.dx.command.dexer.Main$1.processFileBytes(Main.ja
>>>>>>>>>>> va:398)
>>>>>>>>>>>  at com.android.dx.cf.direct.ClassPathOpener.processArchive(Clas
>>>>>>>>>>> sPathOpener.java:245)
>>>>>>>>>>> at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPat
>>>>>>>>>>> hOpener.java:131)
>>>>>>>>>>>  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOp
>>>>>>>>>>> ener.java:109)
>>>>>>>>>>> at com.android.dx.command.dexer.Main.processOne(Main.java:422)
>>>>>>>>>>>  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:
>>>>>>>>>>> 333)
>>>>>>>>>>> at com.android.dx.command.dexer.Main.run(Main.java:209)
>>>>>>>>>>>  at com.android.dx.command.dexer.Main.main(Main.java:174)
>>>>>>>>>>> at com.android.dx.command.Main.main(Main.java:91)
>>>>>>>>>>> 1 error; aborting
>>>>>>>>>>> :HelloCBLite:dexDebug FAILED
>>>>>>>>>>>
>>>>>>>>>>> FAILURE: Build failed with an exception.
>>>>>>>>>>>
>>>>>>>>>>> * What went wrong:
>>>>>>>>>>> Execution failed for task ':HelloCBLite:dexDebug'.
>>>>>>>>>>> > Running /Applications/Android 
>>>>>>>>>>> > Studio.app/sdk/build-tools/android-4.2.2/dx 
>>>>>>>>>>> failed. See output
>>>>>>>>>>>
>>>>>>>>>>> * Try:
>>>>>>>>>>> Run with --stacktrace option to get the stack trace. Run with 
>>>>>>>>>>> --info or --debug option to get more log output. 
>>>>>>>>>>>  
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> From the error, it looks like it's trying to add in classes from 
>>>>>>>>>>> android-support-v4.jar into the classes.dex, which have already 
>>>>>>>>>>> been added 
>>>>>>>>>>> since they were included in the dependency .aar.  
>>>>>>>>>>>
>>>>>>>>>>> Is the .aar of a library supposed to contain android-support-v4.
>>>>>>>>>>> jar?  
>>>>>>>>>>>
>>>>>>>>>>>  
>>>>>>>>>>>  -- 
>>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>>> Google Groups "adt-dev" group.
>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from 
>>>>>>>>>>> it, send an email to [email protected].
>>>>>>>>>>>
>>>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out
>>>>>>>>>>> .
>>>>>>>>>>>  
>>>>>>>>>>>  
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> -- 
>>>>>>>>>> Xavier Ducrohet
>>>>>>>>>> Android SDK Tech Lead
>>>>>>>>>> Google Inc.
>>>>>>>>>> http://developer.android.com | http://tools.android.com
>>>>>>>>>>
>>>>>>>>>> Please do not send me questions directly. Thanks! 
>>>>>>>>>>
>>>>>>>>>  -- 
>>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>>> Groups "adt-dev" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>>> send an email to [email protected].
>>>>>>>>>
>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>  
>>>>>>>>>  
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> Xavier Ducrohet
>>>>>>>> Android SDK Tech Lead
>>>>>>>> Google Inc.
>>>>>>>> http://developer.android.com | http://tools.android.com
>>>>>>>>
>>>>>>>> Please do not send me questions directly. Thanks! 
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to a topic in 
>>>>>>>> the Google Groups "adt-dev" group.
>>>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>>>>> topic/adt-dev/l1gELhPSSkM/unsubscribe.
>>>>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>>>>> [email protected].
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>  
>>>>>>>>  
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> Best regards, 
>>>>>>> Roman Mazur 
>>>>>>>
>>>>>>> Head of Android/Java Unit at Stanfy (http://stanfy.com.ua)
>>>>>>> Skype: roman.mazur.f
>>>>>>> LinkedIn: http://ua.linkedin.com/in/romanmazur
>>>>>>> Twitter: http://twitter.com/roman_mazur
>>>>>>>  
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "adt-dev" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>  
>>>>>>>  
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Xavier Ducrohet
>>>>>> Android SDK Tech Lead
>>>>>> Google Inc.
>>>>>> http://developer.android.com | http://tools.android.com
>>>>>>
>>>>>> Please do not send me questions directly. Thanks! 
>>>>>>
>>>>>  -- 
>>>> You received this message because you are subscribed to a topic in the 
>>>> Google Groups "adt-dev" group.
>>>> To unsubscribe from this topic, visit 
>>>> https://groups.google.com/d/topic/adt-dev/l1gELhPSSkM/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to 
>>>> [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Best regards, 
>>> Roman Mazur 
>>>
>>> Software engineer at Stanfy (http://stanfy.com.ua)
>>> Skype: roman.mazur.f
>>> LinkedIn: http://ua.linkedin.com/in/romanmazur
>>> Twitter: http://twitter.com/roman_mazur
>>>  
>>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to