android studio-gradle打包Android程序,如何打包时不包含依赖包

问题描述

gradle打包Android程序,如何打包时不包含依赖包
使用gradle打包Android程序,希望不包含依赖的lib中的jar包,就像在eclipse的build Path中勾掉依赖,同理下图的操作怎么在gradle的构建打包中实现

解决方案

解决方案二:
楼主有啥解决思路吗?

解决方案三:
https://stackoverflow.com/questions/16107477/gradle-how-to-make-a-compile-scope-file-dependency-excluded-in-packaging

There probably is a cleaner and simpler solution but you could then specify a custom configuration:

configurations {
compileOnly
}
and then specify all dependencies:

dependencies {
compile fileTree(dir: 'dependencies/compile/archive' include: '*.jar' exclude: 'management.jar')
compileOnly files('dependencies/compile/archive/management.jar')
}
Finally add the compileOnly configuration to classpaths of all source sets

sourceSets.all {
compileClasspath += configurations.compileOnly
}
This way management.jar should be on the classpath for compilation but won't be packaged.

EDIT Only now I fully understand your problem. The following worked for me on a test project.

In core project gradle file:

repositories {
flatDir {
dirs 'dependencies/compile/archive'
}
}

dependencies {
compile fileTree(dir: 'dependencies/compile/archive' include: '*.jar' exclude: 'management.jar')
compile ':management:'
}
In project that depends on core:

repositories {
flatDir {
dirs new File(project(':core').projectDir 'dependencies/compile/archive')
}
}

dependencies {
compile(project(':core')) {
exclude module: 'management'
}
compileOnly ':management':
}

sourceSets.all {
compileClasspath += configurations.compileOnly
}

时间: 2024-05-08 08:42:27

android studio-gradle打包Android程序,如何打包时不包含依赖包的相关文章

ANDROID studio gradle,外部包

问题描述 ANDROID studio gradle,外部包 解决方案 http://www.cnblogs.com/wuya/p/android-studio-gradle-export-jar-assets.html 解决方案二: 加速Android Studio/Gradle构建android studio 多渠道打包,调试正式包,build.gradle解析 解决方案三: 看人家给你的错误信息,人家要编译时jdk1.7的,你的直接是1.8的了,设置下jdk编译版本吧 解决方案四: 你的j

Android Studio(十一):代码混淆及打包apk

Android Studio相关博客: Android Studio(一):介绍.安装.配置 Android Studio(二):快捷键设置.插件安装 Android Studio(三):设置Android Studio编码 Android Studio(四):Android Studio集成Genymotion Android Studio(五):修改Android Studio项目包名 Android Studio(六):Android Studio添加注释模板 Android Studio

Android studio 3.0上进行多渠道打包遇到的问题小结(超简洁版)

Error:All flavors must now belong to a named flavor dimension. The flavor 'xiaomi' is not assigned to a flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html Android studio 3.0上进行多渠道打包时编译时出现这个错误 多渠道

android studio gradle failed问题

问题描述 android studio gradle failed问题 本人是安卓实习生一枚,遇到这个问题,求大神解答. Error:Unable to start the daemon process.This problem might be caused by incorrect configuration of the daemon.For example an unrecognized jvm option is used.Please refer to the user guide

在android studio中新建android gradle project的时候connect refused:connect或者卡在building project...或Refreshing

 在android studio中新建android gradle project的时候connect refused:connect或者卡在building project...或Refreshing xxx gradle project === 原因是: gradle在创建时需要联网,不然的话会失败,我虽然可以联网,但是不能访问gradle网站或者下载不了,所以不行. 感谢伟大的GFW,两种方法  1. 使用代理 --- 翻墙就可以了 - 启动XX门 - android studio ->

android studio真机调试 程序安装位置?

问题描述 android studio真机调试 程序安装位置? android studio真机调试 ,找不到程序的安装位置. Log.i("sbsb",getApplicationContext().getFilesDir().getAbsolutePath()); 结果为:/data/data/com.sbsb.photoupload/files 但是手机中并不存在这个路径..这是怎么回事? 解决方案 有的文件在电脑上就是看不到,你服不服 解决方案二: Android Studio

android studio gradle问题

问题描述 android studio gradle问题 Error:Could not run build action using Gradle installation 'C:Program FilesAndroidAndroid Studiogradlegradle-2.8'.这个是什么问题啊 我一直用的好好的啊 解决方案 clean一下试试呗 解决方案二: gradle有问题,可以关闭as打开试试,实在不行重新下载一个gradle

Android Studio Gradle下载位置在哪?

问题描述 Android Studio Gradle下载位置在哪? 找了半天不知道在哪儿下载- -|| 求告知 解决方案 android studio 用gradle 下载 jar 文件目录Android Studio自定义gradle下载路径Android studio的安装和下载Gradle 解决方案二: 查找你项目里面的 gradle.properties 文件 里面有

visual studio 2010-关于VS2010打包安装程序,安装时,选择安装文件夹界面中的磁盘开销的问题,求大神指导

问题描述 关于VS2010打包安装程序,安装时,选择安装文件夹界面中的磁盘开销的问题,求大神指导 用VS2010打包的安装程序,安装时的选择安装文件夹界面 我想把磁盘开销去掉,或者换成下图这样的"所需空间"和"可用空间",不知道打包的时候,在哪设置 求指导 解决方案 最简单的是用第三方的打包工具,比如installshield,它支持对话框自定义.想怎么做就怎么做. 解决方案二: 安装程序的安装界面为乱码的问题