使用摇篮与现有的Andr​​oid项目 [英] Using Gradle with an existing Android project

查看:114
本文介绍了使用摇篮与现有的Andr​​oid项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下结构的现有的Andr​​oid项目:

   - 项目名
 -  AndroidManifest.xml中
 -  local.properties
 -  project.properties

 -  资产
 - 库(包含所有罐子)
 - 模块(包含所有库项目我的项目依赖于)
 - 资源

 -  SRC
---- COM /空间/项目名称(我所有的类,包括主要活动在这里)
 

我没有使用任何特定的编译系统已经建立我的项目超过了Android Studio IDE的默认提供的另外一个(尽管该项目与的IntelliJ CE最初创建。

我想用摇篮的Andr​​oid插件,做我的构建过程中的一些工作。 我曾尝试多种配置,以实现这一点,并没有每次完成一个成功的构建。

什么是在这种情况下建议的方法?我要改变我的项目结构?或者是有可能利用现有的结构配置摇篮?

任何帮助将是很大的AP preciated。

谢谢!

解决方案
  

什么是在这种情况下建议的方法?我要改变我   项目结构?或者是有可能使用配置摇篮   现有的结构?

这是完全有可能利用现有的结构配置摇篮。

您需要一个build.gradle添加到每个库项目。您还需要无添加一个build.gradle和settings.gradle文件到项目根文件夹。

应该是这样的:

 项目名
    build.gradle<<<<<<
    settings.gradle<<<<<<
    AndroidManifest.xml中
    local.properties
    project.properties
    资产
    水库
    SRC
    库
    模块
       模块1
          build.gradle<<<<<<
       模块2
          build.gradle<<<<<<
       module3
          build.gradle<<<<<<
 

在settings.gradle你需要包括文件夹,如果你的主要项目是在一个子文件夹中还应该包括所有项目,这是不是在这样的。

settings.gradle应该是这样的:

 包括':模块:模块1',':模块:模块2',':模块:模块2'
 

主体工程build.gradle应该有:

 相关性{
        编译文件树(导演:库,包括:的* .jar)
        编制项目(':模块:模块1)
        编制项目(':模块:模块2)
        编制项目(':模块:module3)
    }
 

I have an existing Android project with the following structure:

- ProjectName
-- AndroidManifest.xml
-- local.properties
-- project.properties

-- assets
-- libs    (containing all jars)
-- modules (containing all library projects my project depends on)
-- res

-- src
---- com/namespace/projectname (all my classes including main activity are here)

I haven't been using any specific build system to build my project other than the one provided by default with the Android Studio IDE (though the project was originally created with IntelliJ CE.

I would like to use Gradle with the android plugin and do some work on my build process. I have tried several configurations in order to achieve this and have failed to complete a successful build every time.

What's the recommended approach in this scenario? should I change my project structure? or is it possible to configure gradle using the existing structure?

Any help would be greatly appreciated.

Thanks!

解决方案

What's the recommended approach in this scenario? should I change my project structure? or is it possible to configure gradle using the existing structure?

It's perfectly possible to configure gradle using your existing structure.

You need to add a build.gradle to each library project. You also need no add a build.gradle and a settings.gradle files to the project root folder.

Should be like this:

  ProjectName
    build.gradle     <<<<<<
    settings.gradle  <<<<<<
    AndroidManifest.xml
    local.properties
    project.properties
    assets
    res
    src
    libs    
    modules 
       module1
          build.gradle  <<<<<<
       module2
          build.gradle  <<<<<<
       module3
          build.gradle  <<<<<<

In settings.gradle you need to include all projects folders, if your main project was in a subfolder it should also be included, which is not in the case.

settings.gradle should look like this:

include ':modules:module1', ':modules:module2', ':modules:module2'

build.gradle of the main project should have:

dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile project(':modules:module1') 
        compile project(':modules:module2') 
        compile project(':modules:module3') 
    }

这篇关于使用摇篮与现有的Andr​​oid项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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