本文介绍了多的Andr​​oid应用程序包的apk从单一来源$ C ​​$ C文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个Android构建系统的程序,命令行或Eclipse中,从一个单一来源$ C ​​$ CBase的生成数的apk文件。一些常见的原因 - 具有特定版本有不同的要求,或免费和付费版本市场

I would like an Android build system procedure, command line or Eclipse, to generate several .apk files from a single source codebase. Some common reasons for this - having specific versions for markets with different requirements or a free and paid version.

此问题的不是的关于:

  • 包装共享code到Android库,或到外部Java罐

  • Packaging shared code into Android libraries or into external Java jars

生产调试与签署发布的apk

谷歌你可能需要创建单独的Andr​​oid项目,每个APK你打算发布这样就可以适当地单独开发它们,你可以通过简单地复制现有的项目,并给它一个新的名字做到这一点。然后,他们亲切地建议使用图书馆,我明白了。然后,他们在通过完全何况我到底想要什么:

Google says "you probably need to create separate Android projects for each APK you intend to publish so that you can appropriately develop them separately. You can do this by simply duplicating your existing project and give it a new name." Then they kindly suggest using libraries, which I understand. Then, they mention in passing exactly what I do want: "a build system that can output different resources based on the build configuration"

  • 我知道,要实现条件编译中的 JAVA 的人能键关机公共静态最后的变量。有一个example的调整这样的值在build.xml文件。一个Android Ant构建配置这或链接到一个开放源码软件项目做,现在的任何更完整的例子吗?顺便说一句,build.xml文件是自动生成的,但我看到有人盗号的,所以如何运作的?

  • I know that to accomplish conditional compilation in JAVA one can key off a 'public static final' variable. There is an example of tweaking such a value in build.xml. Any more complete example of an Android Ant build configuration for this or a link to an OSS project doing that now, please? BTW, build.xml is auto-generated, but I have seen people hacking it, so how does that work?

随着的Manifest.xml为包=com.example.appname宣布,如果需要输出的改变是名称的多个.apks包名,是坚持了一个单独的项目为每个

With the package name declared in Manifest.xml as package="com.example.appname", if one needs to emit multiple .apks that vary that name, is one stuck with a separate project for each?

推荐答案

我产生2个不同的APK的从一个单一的源代码树(演示和生产)用3小的修改:

I'm generating 2 different APK's (demo and production) from one single source tree with 3 small modifications:

1)我有公共静态最后的DEMO = TRUE; //错误; 在我的应用程序类,并根据该值我用来切换演示/生产要素之间code

1) I have public static final DEMO=true; //false; in my Application class and depending on that value I used to switch code between demo/production features

2)有2个主要活动,如:

2) There are 2 main activities, like:

package mypackage;
public class MyProduction extends Activity
{
    //blah-blah
}

package mypackage.demo;
public class MyDemoActivity extends mypackage.MyProductionActivity
{
    //blah-blah
}

3)而在最后2个独立的的Andr​​oidManifest.xml 文件指向不同的发射活动,根据演示/生产开关

3) And in the end 2 separate AndroidManifest.xml files which points to different launcher activities depending on demo/production switch

我在2 APK的手动开关,但看到自动写入小蚂蚁任务,它们之间进行切换不在话下

I'm switching between 2 APK's manually, but see nothing difficult in writing small ANT task to switch between them automatically

这篇关于多的Andr​​oid应用程序包的apk从单一来源$ C ​​$ C文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:45