android gradle 教程stuido怎么修改gradle

35被浏览5653分享邀请回答2514 条评论分享收藏感谢收起4添加评论分享收藏感谢收起gradle - Renaming modules in Android Studio? - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
I picked the wrong name of a specific module which I imported to the Gradle project in Android Studio.
In this face I want to rename module Facebook1 to Facebook.
Is this possible in Gradle project and how to do it?
20.3k47162278
Android Studio >= 1.4.1
Right click the module -> Refactor -> Rename.
Enter the new name of the module, click OK.
Older versions of Android Studio
The following worked for me, tested in Android Studio (AS) 1.1 & 1.0.2, directly after importing a project.
Under the 'Android' tree view (ATV),
Right click the module name: app, Refactor -> Rename (to myApp, click ok)
Open settings.gradle
Change ':app' to ':myApp', and save
You will be prompted to 'Sync Now', do it (the prompt is a blue link above the file)
(Your project will disappear from ATV, but don't worry, just exit AS)
From a file manager (outside of Android Studio), open your project root directory, and rename the folder app to myApp
Re-open your project in AS, and you will see your module and Gradle scripts re-appear under ATV! :)
Congratulations - your module has now been renamed!
(whew, time for some tea)
4,30973390
1,40011015
In the project view on the left in Android Studio,
right click on the module whose name you want to change
select 'refactor' -> 'rename'
choose the rename module option
follow step 1 - 2 and then rename the directory too
Android Studio 1.3.2,
1. switch Project view on the left in Android Studio
2. right click module which want to change -> Refactor -> Rename
3. do both "Rename directory" and "Rename module"
4. open settings.gradle, change module name
5. Build -> Clean Project
You can do it manually, with or without changing the folder structure (consider not change it for minor impact on version controlling)
Changing folder name accordingly
1- open settings.gradle and change the name of your module (exemple from ':facebook1' to ':facebook')
2- change the folder name accordingly (from xxx/facebook1 to xxx/facebook)
3- If other Modules have dependencies on it: open the corresponding build.gradle and change dependency (from comile project(':facebook1') to comile project(':facebook') )
Without changing folder name
1- open settings.gradle and change the name of your module (exemple from ':facebook1' to ':facebook')
2- add a new line on "settings.gradle":
project(':facebook').projectDir = new File(settingsDir, '/facebook1')
3- If other Modules have dependencies on it: open the corresponding build.gradle and change dependency (from comile project(':facebook1') to comile project(':facebook') )
In AndroidStudio 2.2.2 renaming the module alone via refactor/rename worked for me. (32-bit linux Mint)
The rename dialog presents two options: "directory" or "module" (radio buttons so mutually exclusive, at least in one pass).
I wasn't sure which to pick so I ended here looking for an answer.
One answer said "do both" as two steps, another answer said "do module, then directory" as two steps.
So I chose "module" first.
To my surprise that was all that was needed, both module and directory were changed. settings.gradle was updated by the refactor/rename in the one step as well.
"gradle synce" and "clean build" were also triggered.
Upon build to my tablet, no complaint about the name change.
just adding this answer in case someone else with 2.2.2 or later is unsure which to pick.
Also to re-iterate what others have said, back up your project first.
This is working for me in Android Studio 1.2.1.1
Premise: I do NOT use the refactor function of Android Studio to rename the module
These are the steps I perform:
Rename the folder of the module (directly in the file system)
Modify the setting.gradle file accordingly (directly in the file system)
Open the project in Android Studio
That's all.
Different people seem to have success with different methods, but when I wanted to rename my project from:
com.example.myname.projectname
<pany.projectname
I tried everything and the only way I got it to work in the end was:
1) Exit Android Studio
2) back everything up! (find your project folder and make a copy of it)
3) Find and replace all instances of com.example.myname.projectname pany.projectname
Note that there are five places (actually it probably depends on your project, I had five) where you need to rename folders, as it creates subfolders called com\example\myname\projectname:
project\app\src\main\java
project\app\src\androidTest\java
project\app\build\generated\source\buildConfig\debug\
project\app\build\generated\source\buildConfig\test\
project\app\build\generated\source\r\debug\
Also, in project.idea\ there is a file called workspace.xml - in that file you'll need to find the text com\example\myname\projectname
Otherwise, do a search through the project directory to find "com.example.myname.projectname" and replace with "pany.projectname"
4) Open Android Studio again.
if the initial project directory name is the same (possibly if the project name itself is the same?) it will reopen if you had it open last time, otherwise you should be able to open as normal.
5) Go to File - Project Structure (CONTROL+ALT+SHIFT+S).
6) Under "Flavors", change the application ID to the new name.
7) Excit Android Studio and restart it.
8) Now you should be able to build your project.
9) Go have a drink, that was a lot more effort than it should have been!
One really important note, you can only have ASCII letters in your package name (you may be able to have numbers, but not as the first character).
Java itself allows numbers to start a package name, but Android does not:
I was trying to rename
My workaround (and from a look around the apps on my phone it seems to be what others are doing) is if you wanted a number at the start of either your company name or app name, write the word - instead of com.123company.55project perhaps use com.onetwothreecompany.fiftyfiveproject
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
The week&#39;s top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled解决android studio Gradle警告GBK编码的不可映射字符的问题&&categories:&&author:今天用android studio来写代码,然后在代码中加了中文注释导致无法编译:提示错误:“ Gradle: 警告:编码 GBK 的不可映射字符”。网络上 查找各种解决方法, 也没有最终解决, 可以通过到cmd中进行编译, 找到错误的代码行, 可以进行删除相关注释,一般都能解决,但是不是最好的办法。下面是从网络上搜索的解决方法,如下(其实我的程序这么操作后,也没有解决, 我是用下面的另外方法进行的解决) 网上也有挺多解决的方法,但是看得不是很明显,这里截图给大家分享一下:这里是中文代码注释android studio代码中的 中文注释,容易引起编译问题,程序没办法启动编译出错,在项目下的build.gradle下添加以下代码即可解决。复制代码&在图中代码中添加相关设置可以解决android studio中文编码问题tasks.withType(Compile) {
options.encoding = &#8220;UTF-8&#8243;}截图看起来更加清晰哈.设置android studio的编码方式为utf-8&参照上面的过程进行了设置, 但是在我的项目中, 问题还是存在,后来采用源代码转换成gbk的方式,问题解决,过程如下:1. 选择源代码文件, 选择其中文件编码选择文件的编码方式, 如图, 选择File encoding子菜单2. 在弹出菜单中选择 gbk类型选择GBK编码方式&3. 最后选择转换当前文件代码 到 gbk方式, 然后在编译在android stuido的源代码文件中选择 转换当前代码到目标编码方式解决乱码的编译问题近期文章
分类目录选择分类目录书路&&(10)儿童画&&(121)&&&儿童作品&&(82)&&&儿童画教程&&(24)原创&&(127)&&&0基础编程&&(23)&&&android&&(9)&&&hadoop&&(18)&&&java原创&&(2)&&&livewriter&&(11)&&&nginx&&(52)资料&&(1,055)&&&android资料&&(83)&&&java资料&&(74)&&&linux资料&&(36)&&&mq&&(24)&&&mysql资料&&(34)&&&nginx资料&&(17)&&&svn&&(9)&&&wordpress&&(48)&&&搜索资料&&(45) 文章归档 选择月份 2017年十二月 &(7) 2017年十一月 &(3) 2017年九月 &(3) 2017年八月 &(1) 2017年七月 &(15) 2017年六月 &(23) 2017年五月 &(35) 2017年四月 &(38) 2017年三月 &(20) 2017年二月 &(5) 2017年一月 &(9) 2016年十二月 &(8) 2016年十一月 &(1) 2016年十月 &(10) 2016年九月 &(5) 2016年八月 &(8) 2016年七月 &(6) 2016年六月 &(9) 2016年五月 &(14) 2016年四月 &(6) 2016年三月 &(21) 2016年二月 &(11) 2016年一月 &(15) 2015年十二月 &(18) 2015年十一月 &(14) 2015年十月 &(6) 2015年九月 &(6) 2015年八月 &(7) 2015年七月 &(11) 2015年六月 &(19) 2015年五月 &(27) 2015年四月 &(19) 2015年三月 &(35) 2015年二月 &(38) 2015年一月 &(20) 2014年十二月 &(8) 2014年十一月 &(8) 2014年十月 &(3) 2014年九月 &(3) 2014年八月 &(3) 2014年七月 &(4) 2014年六月 &(3) 2014年五月 &(7) 2014年四月 &(9) 2014年三月 &(8) 2014年二月 &(8) 2014年一月 &(11) 2013年十二月 &(11) 2013年十一月 &(9) 2013年十月 &(40) 2013年九月 &(79) 2013年八月 &(50) 2013年七月 &(68) 2013年六月 &(50) 2013年五月 &(59) 2013年四月 &(65) 2013年三月 &(59) 2013年二月 &(20) 2013年一月 &(59) 2012年十二月 &(52) 2012年十一月 &(91) 2012年十月 &(23)Android Studio gradle配置详解
AppExtension类及其属性
可能大部分人看到AppExtension类会感觉到非常的陌生,其实我们在app中的build.gradle中填写配置信息的时候,经常看到它,它是什么呢?
如果你按ctrl+鼠标左键对着android{},点击进去就知道了,其实android{&}表示的就是AppExtension这个类。
我们再来看看AppExtension继承关系:
除了AppExtension之外还有2个类与之相似,LibraryExtension和TestExtension
如果是module项目作为lib使用,那么lib下的build.gradle中的android对应的是LibraryExtension
AppExtension的属性
aaptOptions:aapt是一个可以将资源文件编译成二进制文件的工具。aaptOptions表示aapt工具设置的可选项参数。 adbExecutable:adb从编译sdk时执行 adbOptions:adb的可选项参数 applicationVariants:应用变体列表 ==buildToolsVersion==:构建工具版本(必要的) buildTypes:构建类型(一般是release和debug,还可以自定义) compileOptions:编译可选项参数 ==compileSdkVersion==:编译sdk版本(必要的) dataBinding:Data Binding可选项参数() defualtConfig:默认配置,对于所有的打包项目 defualtPublishConfig:默认是release。 dexOptions:Dex可选项参数。 externalNativeBuild:native编译支持。参考 flavorDimensionList: generatePureSplits:是否拆成多个APK jacoco:JaCoCo可选项参数 lintOptions:Lint工具可选项参数 ndkDirectory:ndk目录(一般在local.properties中) packagingOptions:packaging的可选参数 productFlavors:项目所有flavor publishNonDefualt:不仅仅使用默认的publish artifacts。可参考defualtPublishConfig。 resourcePrefix:创建新资源时使用的前缀。 sdkDirectory:sdk目录(一般在local.properties中) signingConfigs:签名文件的可选项参数 sourceSets:资源文件目录指定(中有自己的AndroidSourceSets,这个一般用于assets,jin等目录) splits:splits类型。 testBuildType:测试构建类型 testOptions:测试可选项参数 testVariants:测试变体 unitTestVariants:单元测试变体 variantFilter:变体过滤器
加粗的表示DSL语言的闭包
buildTypes { }
AppExtension的方法:
- flavorDimensions(dimension):指定flavor名称
- useLibraray(name):请求使用一个lib库
- useLibrary(name,required):与上面解释一样。
AppExtension的配置闭包(Configration blocks)
与app中build.gradle中android{}一样,代码中由AppExtension类表示。其他的配置闭包也一样。
aaptOptions{}
aaptOptions{}代码由AaptOptions类表示。
AaptOptions的属性:
1.additionalParameters:额外参数,List类型。
2.cruncherEnabled:如果PNG图片是否可以大量快速的处理,boolean类型。 true表示可以。
3.cruncherProcesses:快速处理,可能需要更多的内存和CPU。int类型。默认0,值越大处理越快,需要的内存和CPU也越大。
4.failOnMissingConfigEntry:如果没有找到一个配置,就返回一个错误。Boolean值,默认false。
5.ignoreAssetsPattern:忽略Assets模块。
6.moCompress:拓展文件不会打包进apk中。
用法(详细用法可能需要去看看文档了):
aaptOptions{
cruncherEnabled true//快速处理PNG图片
adbOption{}
adbOptions{}对应的是AdbOptions
AdbOptions的属性:
1.installOptions:apk安装的可选参数。
2.timeOutInMs:使用adb的超时时间。
buildTypes{}
buildTypes{}对应的是BuildType类
buildTypes的属性:
1.applicationIdSuffix:应用id后缀(给Applica)
2.consumerProguardFiles:混淆文件包含在arr包中。
3.debuggable:是否生成一个debug的apk
4.embedMicroApp:可穿戴设备app是否可以使用这个编译类型
5.javaCompileOption:编译配置参数
6.jniDebuggable:这个编译类型的配置是否可以与debuggable的native代码生成一个apk
7.manifestPlaceholders:清单占位符
8.minifyEnabled:是否缩小
9.multiDexEnabled:是否拆成多个Dex
10.multiDexKeepFile:指定文本文件编译进主Dex文件中
11.multiDexKeepProguard:指定混淆文件编译进主Dex文件中
12.name:build type的名字
13.proguardFiles:混淆文件
14.pseudoLocalesEnabled:是否生成伪现场apk(如果没有提供混淆规则文件,则设置默认的混淆规则文件(SDK/tools/proguard/proguard-android.txt))
15.renderscriptDebuggable:使用RenderScript编译器的优化级别。
16.shrinkResources:是否去除未利用的资源,默认false,表示不去除。
17.signingConfig:签名配置
18.testCoverageEnabled:测试覆盖率是否被激活。
19.useJack:过时
20.versionNameSuffix:版本名称后缀
21.zipAlignEnable:是否使用zipalign工具压缩。
------------------------------------------------------
buildType的方法:
1.buildConfigField(type,name,value):添加一个变量生成BuildConfig类。
2.consumeProguardFile(proguardFile):添加一个混淆文件进arr包。
3.consumeProguardFile(proguardFiles):添加混淆文件进arr包。
4.externalNativeBuild(action):配置本地的build选项。
5.initWith:复制这个build类型的所有属性。
6.proguardFile(proguardFile):添加一个新的混淆配置文件。
7.proguradFiles(files):添加新的混淆文件
8.resValue(type,name,value):添加一个新的生成资源
9.setProguardFiles(proguardFileIterable):设置一个混淆配置文件。
------------------------------------------------------------
buildType用法:
buildTypes {
minifyEnabled true
proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;), &#39;proguard-rules.pro&#39;
shrinkResources true
zipAlignEnabled true
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;), &#39;proguard-rules.pro&#39;
shrinkResources true
zipAlignEnabled true
debuggable true
compileOptions{}
compileOptions{}对应的是CompileOptions
CompileOptions的属性:
1.encoding:Java源文件的编码格式
2.incremental:是否应该使用Java编写的Gradle新的增量模型
3.sourceCompatibility:指定编译编译.java文件的jdk版本
4.targetCompatibility:确保class文件与targetCompatibility指定版本,或者更新的java兼容
dataBinding{}
dataBinding{}对应的是DataBindingOptions
DataBindingOptions的属性:
1.addDefualtAdapters:是否添加一个默认的data binding适配器。默认true。
2.enabled:是否使用data binding
3.version:data binding使用版本
dataBinding的使用:
dataBinding{
enabled true
defualtConfig{}
defaultConfig{}是所有flavor都共有的配置。
英文解释:The default configuration, inherited by all product flavors (if any are defined).
defaultConfig的使用:
defaultConfig {
applicationId &com.example.zhang.demo&
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName &1.0&
testInstrumentationRunner &android.support.test.runner.AndroidJUnitRunner&
如果项目中包含多个Module,可以将共有的minSdkVersion和targetSdkVersion抽取到Project中的build.gradle文件中。具体细节下一章节。
dexOptions{}
dexOptions{}对应的是DexOptions
DexOptions属性:
1.additionalParameters:给dx添加一系列附加的参数
2.javaMaxHeapSize:当调用dx时指定-Xmx值。
3.jumboMode:使用jumbo(庞大的)模式
4.keepRuntimeAnnotatedClasses:保持所有类中的运行时的注解在主Dex中。
5.maxProcessCount:可以使用Dex的最大并发进程数。默认为4。
6.optimize:运行在dx编译器是否有optimize标记。
7.preDexLibraries:是否预先dex库,它可以改善增量的生成,但是在clear build可能会变慢
8.threadCount:当dx运行时使用的线程的数量。默认4个。
dexOptions{}的用法:
dexOptions {
preDexLibraries
javaMaxHeapSize &4g&
externalNativeBuild{}
externalNativeBuild{}对应的是ExternalNativeBuild
ExternalNativeBuild的属性:
1.cmake:CMake工具编译选项。
2.ndkBuild:ndk-build选项。
在externalNativeBuild{}中有2个模块,cmake{}和ndkBuild{}模块
------------------------------------------------
cmake{}对应的是CmakeOptions
CmakeOption的属性:
1.path:你的CmakeLists.txt编译脚本的相对路径。
--------------------------------------------------
ndkBuild{}对应的是NdkBuildOptions
NdkBuildOptions的属性:
1.path:你的Android.mk文件的相对路径。
--------------------------------------------------
externalNativeBuild{}的用法:
externalNativeBuild{
path file(&src\\main\\jni\\Android.mk&)
path &src/main/cpp/CMakeLists.txt&
jacoco{}对应于JacocoOptions
JacocoOptions的属性:
1.version:过时
英文原文:
note: this property is deprecated and will be removed in a future version of the plugin.
lintOptions{}
lintOptions{}对应于LintOptions
LintOptions的属性:
1.abortOnError:如果发现错误,lint工具是否应该退出这个程序。true表示退出。
2.absolutePaths:是否在输出错误的时候,lint应该展示出全路径。默认是相对路径,也就是默认false。
3.check:精确的检查(搜集)问题的集合,默认情况下,任何问题都可以通过LintOptions.getEnable()启用,没有问题可以通过LintOptions.getDisable()使之无效。
4.checkAllWarnings:是否检查所有警告,包括那些默认关闭。
5.disable:通过id&#39;s来压制这个问题,允许修改
6.enable:通过id&#39;s来处理这个问题,循序修改,他会将添加id,并返回一个集合。
7.explainIssues:返回lint是否包含错误问题的解释(注意:HTML和XML报告会无条件的去做,忽略这个设置)。
8.htmlOutput:html输出方式。
9.htmlReport:我们应该是否写一个HTML报告,默认true, 这个使用场景由LintOptions.getHtmlOutput()控制。
10.ignoreWarings:lint仅仅检查错误,忽略警告。
11.lintConfig:默认配置文件作为备份。
12.noLines:lint在输出错误日志的时候,是否包含行数。默认true。
13.quiet:lint是否应该quiet(安静)。如:报告文件写入路径,不写消息。
14.severityOverrides:An optional map of severity overrides. The map maps from issue id&#39;s to the corresponding severity to use, which must be &fatal&, &error&, &warning&, or &ignore&.
15.showAll:lint是否包含所有的输出。
16.textOutput:文本输出方式。
17.textReport:是否是文本报告写入,默认false。
18.warningAsErrors:lint是否把警告当做错误来处理。
19.xmlOutput:XML输出方式。
20.xmlReport:XML格式写入报告,默认true。
------------------------------------------------
LintOptions的方法:
1.check(id):检查这个id的问题的集合
2.check(ids):
3.disable(id):将id添加到不用启动的问题集
4.disable(ids):
5.enable(id):将id添加到启动的问题集
6.enable(ids)
7.error(id):将id添加到错误的问题集
8.error(ids)
9.fatal(id):将id添加到fatal级别的问题集
10.fatal(ids)
11.ignore(id):将id添加到ignore级别的问题集
12.ignore(ids)
13.waring(id):将id添加到waring级别的问题集
14.waring(ids)
------------------------------------------------
lintOptions{}的一般用法:
lintOptions {
abortOnError false
packagingOptions{}
packagingOptions{}对应的是PackagingOptions
Packaging options有三组路径:first-picks,merges和excludes:
packagingOptions{}的用法:
packagingOptions {
pickFirsts = [] // Not really needed because the default is empty.
merges = []
// Not really needed because the default is empty.
excludes = []
productFlavors{}
productFlavors{}对应的是ProductFlavors
ProductFlavors的属性:
1.applicationId:应用程序ID。
2.applicationIdSuffix:应用程序ID后缀。
3.consumerProguardFiles:混淆规则文件被包含在aar包中。
4.dimension:flavor名称的尺寸。
5.externalNativeBuild:详情见externalNativeBuild{}
6.flavorDeminsion:过时
7.generatedDensities:过时
8.jackOption:jack配置可选项。
9.javaCompileOptions:Java编译配置参数
10.manifestPlaceholders:manifest占位符
11.multiDexEnabled:是否进行dex拆分
12.multiDexKeepFile:文本文件编译进主dex文件中。
13.multiDexKeepProgroud:文本文件作为混淆规则编译进主dex文件中
14.ndk:ndk配置
15.proguardFiles:混淆文件
16.signingConfig:这个flavor的签名配置信息
17.testApplicationId:测试应用ID
18.testFunctionalTest:
19.testHandleProfiling:
20.testInstrumentationRunner:
21.testInstrumentionRunnerArguments:
22.useJack:过时
23.verctorDrawables:生成矢量图支持
24.versionCode:版本号
25.versionName:版本名
26.versionNameSuffix:版本名后缀
27.wearAppUnbundled:是否对嵌入式穿戴app进行拆分模式。如果true,那么这个app将在应用市场被分发为穿戴设备的app。
productFlavor{}的用法:
productFlavors {
googlePlay {
//所有打包配置(批量处理打包渠道--& manifestPlaceholders:设置打包渠道)
productFlavors.all {
flavor -& flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
signingConfig{}
signingConfig{}对应的是SigningConfig
SigningConfig的属性:
1.keyAlias:签名使用key的别名
2.KeyPassword:签名使用的key的密码
3.storeFile:store签名文件
4.storePassword:store签名密码
5.storeType:store签名类型
6.v1SigningEnabled:是否使用jar签名(又名v1签名)。
7.v2SigningEnabled:是否使用apk签名(又名v2签名)。
signingConfig{}的用法:
signingConfigs {
keyAlias &#39;...&#39;
keyPassword &#39;...&#39;
storeFile file(&#39;C:/../Key.jks&#39;)
storePassword &#39;...&#39;
sourceSets{}
sourceSets{}对应的AndroidSourceSet
AndroidSourceSet的属性:
1.aidl:aidl目录
2.assets:assets目录
3.compileConfiguraName:编译配置资源目录。
4.java:java代码目录(需要编译成.class文件)
5.jni:jni资源目录
6.jniLibs:jni库目录
7.manifest:AndroidManifest.xml资源文件
8.name:source set名称。
9.packageConfigurationName:运行时配置的资源集。
10.providedConfigurationName:仅仅编译时配置的资源集。
11.renderscript:RenderScript脚本资源目录
12.res:Android资源目录
13.resource:java资源被复制到输出到javaresource目录
AndroidSourceSet的方法:
1.setRoot(path):资源集的根目录,所有的资源都在这个跟目录下。
sourceSets{}的使用:
sourceSets {
//在main目录中
//assets目录设置
assets.srcDirs = [&#39;assets&#39;]
//jni目录设置
jni.srcDirs &#39;src/main/jni&#39;
//jni库设置
jniLibs.srcDir &#39;src/main/jniLibs&#39;
splits{}对应的是Splites
Splits的属性:
1.abi:ABI设置
2.abiFilters:用于多个apk的ABI筛选列表
3.density:密度设置
4.densityFilters:用于多个apk的密度筛选列表
5.language:语言设置。
6.languageFilters:用于多个apk的语言筛选列表
-----------------------------------------------------
Spiltes对应有三个模块,abi{},density{},language{}
abi{}对应的是AbiSplitOptions
AbiSplitsOptions的属性:
1.applicableFilters:返回此范围的所有适用筛选器的列表。
2.enable:是否在这个范围分裂
3.universalApk:是否创建所有可用的ABIs一个APK。
AbiSplitesOptions的方法:
1.exclude(excludes):排除一些值。
2.include(include):包含一些值。
3.reset():重新设置split配置。
----------------------------------------------------------
density{}对应的是DensitySplitOptions
DensitySplitOptions的属性:
1.applicableFilters:返回此范围的所有适用筛选器的列表。
2.auto:编译是否确定分割&language-*&文件夹中的资源。
3.compatibleScreen:兼容屏幕列表
4.enable:是否拆分
DensitySplitOptions的方法:
1.exclude(exclude):排除一些值
2.include(include):包含一些值
3.reset():重新设置split配置。
-------------------------------------------------------
language{}对应的是LanguageSplitOptions
LanguageSplitOptions的属性:
1.enable:如果true,就是拆分language
LanguageSplitOptions的方法:
1.include(include):包含一个模型。
---------------------------------------------------------
splits{}的用法:
enable true
exclude &#39;ldpi&#39;, &#39;mdpi&#39;
compatibleScreens &#39;normal&#39;, &#39;large&#39;, &#39;xlarge&#39;
生成结果:
app-hdpi-release.apk
app-universal-release.apk
app-xhdpi-release.apk
app-xxhdpi-release.apk
app-xxxhdpi-release.apk
enable true
include &#39;x86&#39;, &#39;armeabi-v7a&#39;, &#39;mips&#39;
universalApk true
这个就是生成不同手机架构的app
testOptions{}
testOptions{}对应的是TestOptions
TestOptions的属性:
1.reportDir:报告目录
2.resultDir:结果目录
3.unitTests:单元测试配置参数
TestOptions包含unitTests{}
-------------------------------------------------------
unitTests{}对应的是UnitTestOptions
UnitTestOptions的属性:
1.returnDefaultValues:无论unmocked方法从android.jar中抛出异常或是默认值(0或null)。
UnitTestOtions的方法:
all(configClosure):配置所有单元测试任务。
-------------------------------------------------
testOptions{}的使用:
testOptions {
resultsDir = &$project.buildDir/foo/results&

我要回帖

更多关于 修改android gradle 的文章

 

随机推荐