在摇篮定制Android的老项目结构 [英] Custom old Android project structure in Gradle

查看:122
本文介绍了在摇篮定制Android的老项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有如下形式的项目结构
结果
SRC结果src_flavor1结果src_flavor2结果RES结果res_flavor1结果res_flavor2
结果
结果
核心逻辑和资源都放在src和res文件夹RESP。加味文件夹只包含两个独立的口味几个文件。
结果
 我试着去定义这个项目结构withing中的build.gradle文件,但havnt发现任何成功。还我试着去使用prductFlavor标记来创建同时构建了两种口味,但没有成功。这样做所有的Andr​​oid Studio的最新版本内

We have a project structure of the form
src
src_flavor1
src_flavor2
res
res_flavor1
res_flavor2

The core logic and resources are placed in src and res folder resp. The flavoured folders only contains few files which separate the two flavors.
Im trying to define this project structure withing the build.gradle file but havnt found any success. Also Im trying to use the prductFlavor tags to create simultaneous builds of the two flavors but no success. Doing all this within the Android Studio latest build

推荐答案

假设你有像这样定义你的口味:

Assuming you have define your flavors like this:

productFlavors {
    flavor1 {
        ...
    }
    flavor2 {
        ...
    }
}

您可以修改每种口味的sourceSets

You can modify the sourceSets of each flavor

android.sourceSets.flavor1 {
    java.srcDirs = ['src_flavor1']
    resources.srcDir = ['res_flavor1']
}

android.sourceSets.flavor2 {
    java.srcDirs = ['src_flavor2']
    resources.srcDir = ['res_flavor2']
}

我希望这帮助...(不要犹豫,加入你的问题更多的细节,因为这将帮助我们来帮助你)

I hope this help... (don't hesitate to add more details about your problems since it will help us to help you)

最后一句话:关于根据我的经验,Android的工作室还不是很稳定的没有的,而不是全功能的没有的gradle这个< - > IDE同步。所以我强烈建议你总是在命令行测试脚本的gradle

Last remark: according my experience, Android-Studio is not very stable yet and not full-featured yet regarding gradle<-->IDE sync. So I strongly suggest you to always test your gradle scripts from the command line.

这篇关于在摇篮定制Android的老项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆