Android Studio Gradle 构建风味 [英] Android Studio Gradle Build Flavors
问题描述
我无法理解 Android Studio 中的 Build Flavors.我试图实现一个简单的事情:通过较小的代码更改构建 2 个已签名的 APK.专业版"APK 只是在 res/layout/
中有一个不同的 drawer.xml
.我在文档和 StackOverflow 上阅读了一些内容,但我没有看到我的 build.gradle
更改发生任何事情.
I am having troubles understanding Build Flavors in Android Studio. I am trying to achieve a simple thing: buidling 2 signed APK's with a minor code change. The "pro" APK just has a different drawer.xml
in res/layout/
. I've read a few things in the Documentation and here on StackOverflow but I don't see anything happen with my build.gradle
changes.
我当前的 build.gradle
文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 17
}
productFlavors {
lite {
packageName = 'com.mikebdev.refuel'
}
pro {
packageName = 'com.mikebdev.refuelpro'
}
}
sourceSets{
android.sourceSets.pro {
res.srcDirs = ['src/main/res_pro']
}
}
}
我创建了一个新文件夹:
I created a new folder:
/src/main/res_pro/layout/drawer.xml
我在这里做错了什么?
编辑
我更新了上面的 build.gradle 文件.
I updated my build.gradle file above.
由于其他一些不稳定性而重置了我的整个 Android Studio 后,我现在可以在左下角选择我的构建变体(lite-debug、lite-release、pro-debug、pro-release)为什么甚至那些调试和发布变体?
After resetting my whole Android Studio because of some other instabilities I am now able to choose in the bottom left corner my build variants (lite-debug, lite-release, pro-debug, pro-release) Why even those debug AND release variants?
这似乎可以正常工作了.
This seems to work now as it should.
我在下面添加了一个答案
I added a answer below
推荐答案
在重置我的整个 Android Studio 因为其他一些不稳定性之后,我现在可以在左下角选择我的构建变体(lite-debug,lite-release,亲调试,亲发布)为什么甚至那些调试和发布变体?
After resetting my whole Android Studio because of some other instabilities I am now able to choose in the bottom left corner my build variants (lite-debug, lite-release, pro-debug, pro-release) Why even those debug AND release variants?
我用模块创建了一个全新的项目,并复制并粘贴了我从 eclipse 导出的旧项目中的所有内容.
I created a whole new Project with Module and copy&pasted everything from my old project which I exported from eclipse a while back in there.
现在可以了.
在我重新安装之前,我的 Android-Studio 有点坏了.崩溃次数比应有的多,一些奇怪的行为等等.
My Android-Studio was kinda broken before my reinstall. More crashes than there should be, some strange behaviors ans such stuff.
这篇关于Android Studio Gradle 构建风味的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!