5

Is there a way to exclude .jar file from .aar file. My project is not running as I have one module that contains a .aar file in which Gson.jar is used as a library and I need it in my main app as well so I need to implement Gson dependency also. When I tried to run my project I got multidex error:

Execution failed for task ':app:transformClassesWithBundleMultiDexListForDevelopmentBuildDebug'.

com.android.build.api.transform.TransformException: Error while generating the main dex list.

Please help me to solve this issue. Thanks

Ehsan Anjum
  • 153
  • 1
  • 10

2 Answers2

2

Finally after a lot of searching I have found solution.

Solution that worked for me:

$ unzip myLib.aar -d tempFolder # or other extracting tool
# Change whatever you need
$ jar cvf myNewLib.aar -C tempFolder/ .

Reference link: Modifying contents of Android .aar file / Converting to and from .zip format

Ehsan Anjum
  • 153
  • 1
  • 10
0

You can have exculde in the targets just like this

 sourceSets.main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
        java {
            exclude '**/VanillaARMv*'
            exclude '**/VanillaX86*'
        }
        resources {
            exclude '**/VanillaARMv*'
            exclude '**/VanillaX86*'
        }
        aidl {
            exclude '**/VanillaARMv*'
            exclude '**/VanillaX86*'
        }
        renderscript {
            exclude '**/VanillaARMv*'
            exclude '**/VanillaX86*'
        }

    }

Here i am excluding whatever i have in VanillaARMv* and in VanillaX86* folders from the target build.

nkalra0123
  • 2,281
  • 16
  • 17
  • 1
    Thank you so much for your response. I don't understand the above script please do let know how can I exclude the Gson library from my module. I have two flavors in my app named as & . Looking forward to get positive response. Thanks – Ehsan Anjum Jan 10 '19 at 12:17
  • 1
    If you can post your build.gradle, i can try to add the exclude property – nkalra0123 Jan 10 '19 at 15:40