Exclude one class file in gradle Android Studio

前端 未结 2 2031
你的背包
你的背包 2020-12-17 06:05

In my projects, I need to import third party jar file and Facebook SDK.

compile files(\'libs/SkinSDK.jar\')
compile \'com.facebook.android:facebook-android-         


        
相关标签:
2条回答
  • 2020-12-17 06:29

    The exclude method of the configuration closure for a dependency excludes transitive dependencies. So, if your module dependency depends on other modules, you can exclude them from your build. You can check out the transitive dependencies of the 'com.facebook.android:facebook-android-sdk:4.14.0' module on its Maven repository info page.

    If the BundleJSONConverter class exists in a transitive dependency, you can exclude the specific module in the same way you are trying now. Just specify the group, the module and the version, like you do for dependencies.

    If you just want to exclude one class for a dependency jar, take a look at the jar jar links tool and its Gradle plugin. It allows you to alter included jars, e.g. to change packages or remove classes.

    The following (shortened) example shows the usage of the plugin and some methods to alter the dependency jar:

    compile jarjar.repackage {
        from 'org.apache.hive:hive-exec:0.13.0.2.1.5.0-695'
    
        archiveBypass "commons*.jar"
        archiveExclude "slf4j*.jar"
    
        classDelete "org.apache.thrift.**"
        classRename 'org.json.**', 'org.anarres.hive.json.@1'
    }
    
    0 讨论(0)
  • 2020-12-17 06:39

    Bumped into similar situation. This is what I did, not elegant as I hoped, but it works:

    1. Rename the jar file (SkinSDK.jar in your case): .zip instead of .jar

    2. Go "inside" the zip file (I'm using DoubleCommander, there are many other utilities for that), or extract it to a temporary folder.

    3. Delete the duplicate class that causes the problem. Go "outside" the zip file.

    4. Rename (or re-pack) the file from .zip to .jar . Compile.

    Hope it works...

    0 讨论(0)
提交回复
热议问题