Android的工作室:迁移复杂的build.xml到的build.gradle [英] Android Studio: Migrate complex build.xml to build.gradle

查看:291
本文介绍了Android的工作室:迁移复杂的build.xml到的build.gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经迁移我的项目从日食到Android工作室成功地和一个默认的build.gradle文件已经生成。该项目建立正确,我可以部署到调试等。

I have migrated my project from eclipse to android studio successfully and a default build.gradle file has been generated. The project builds correctly and I can deploy to debug etc.

真正的问题虽然是(命令行)对,我曾经有一个自定义的蚂蚁建造建筑物释放APK文件(通过命令行调用,而不是出日食)。

The real problem though is building release APK files (from the command line) for which I used to have a custom ant-build (called via command line, not out of eclipse).

我定制的build.xml从SDK文件夹通过进口标准的SDK build.xml文件

My custom build.xml imported the standard sdk build.xml file from the SDK folder via:

<import file="${sdk.dir}/tools/ant/build.xml" />

因此​​,所有我在我的build.xml做的是覆盖目标或挂接到他们通过依赖。

So all I had to do in my build.xml was to override targets or hook into them via "depends".

有一个覆盖一个例子:

<target name="-set-release-mode" depends="-set-mode-check">
    <!--Here I rename my output apk files to something like: myapp-versionFromAndroidManifest.apk -->
</target

和添加依赖一个例子:

<target name="-pre-build" depends="clean">
    <!-- my custom code where I copy resource files, process command line arguments   
     use xpath to extract things like the version from the AndroidManifest.xml and 
     write them into custom xml files etc... -->
</target

所以,总体来说使用蚂蚁,整个事件是非常简单的。但是现在,当涉及到迁移到摇篮我在一个总损失,如何完成同样的,我previously做蚂蚁,具体是:

So overall the whole affair was really simple using ant. But now when it comes to migrating to gradle I am at a total loss, how to accomplish the same that I previously did in ant, specifically:


  1. 用于build.xml还有就是我在蚂蚁构建进口了默认的build.xml - 做一个标准的build.gradle文件中存在的地方,所以我可以检查出定义的任务

  2. 是否有可能的gradle覆盖任务,如果是:怎么样?

  3. 我是pretty一定的依赖,从蚂蚁可以进行的gradle模仿=...,但我不知道如何和还需要回答问题1。

我GOOGLE了一堆教程,也迁移教程一样(不幸的是没有解决我的问题):

I googled a bunch of tutorials, also migration tutorials like (which unfortunately didn't address my issues):

<一个href=\"http://keepsafe-engineering.tumblr.com/post/87818767721/migrating-android-app-from-ant-to-gradle\" rel=\"nofollow\">http://keepsafe-engineering.tumblr.com/post/87818767721/migrating-android-app-from-ant-to-gradle

http://ryanharter.com/blog / 2013/07/17 /迁移功能的Andr​​oid项目到gradle这个/

我也看了从文档的gradle这并不能真正帮助在所有这一章中,因为它没有回答这个问题问题1或2或3:

I also read this chapter from the gradle docs which didn't really help at all, because it does not answer question 1 or 2 or 3 for that matter:

http://www.gradle.org/docs/current/userguide/ ant.html

下面给出了一些有趣的指针,但:

The following gave some interesting pointers though:

http://toastdroid.com/2014/03 / 28 /定制 - 您 - 建立与 - gradle这个/

我也尝试简单地复制从SDK文件夹的默认build.xml文件到我自己的build.xml,然后只需导入的gradle中Ant构建文件并执行构建了踢Ant任务:

I also tried simply copying the default build.xml from the sdk folder into my own build.xml and then simply importing that ant build file in gradle and executing the ant task that kicks of the build:

<target name="release"
            depends="-set-release-mode, -release-obfuscation-check, -package, -post-package, -release-prompt-for-password, -release-nosign, -release-sign, -post-build"
            description="Builds the application in release mode.">
</target>

但我开始运行到该建议,这不是一种选择了,因为默认的build.xml开始引发错误,这似乎涉及到SDK版本问题。我只好绕了很多,因为新的Andr​​oid Studio项目结构的原SDK的build.xml一塌糊涂,所以文件,在那里他们预期等不...

but I started running into problems that suggested this is not an option anymore, since the default build.xml started throwing errors, that seemed related to the SDK version. And I had to mess around a lot with the original sdk build.xml because of the new android studio project structure, so files were not where they were expected etc...

推荐答案


  • 首先,我建议你导入遗留项目到Android
    工作室。它会创建适当的build.gradle脚本你。

  • 然后,你可以通过执行 gradlew任务在列出任务列表
    根项目的。

  • 要依赖于某些任务时,可以使用命令,如 init.dependsOn anotherTask

  • First, I would suggest you import the legacy project to android studio. It will create the appropriate build.gradle script for you.
  • And then, you can list the task list by executing gradlew tasks at the root of your project.
  • To depend on some tasks, you can use command such as init.dependsOn anotherTask.
  • 这篇关于Android的工作室:迁移复杂的build.xml到的build.gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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