在Codename One中管理我的应用程序的演示版/完整版 [英] Managing Demo / Full version of my app in Codename One

查看:33
本文介绍了在Codename One中管理我的应用程序的演示版/完整版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被命令提供2个版本的应用程序:一个演示版/light版(受限制的功能),另一个完整版(所有功能).我的代码中有一个布尔值,它告诉正在运行的那个.它们都可以在模拟器或测试设备(iOS和Android)上按预期运行.

I was ordered to deliver an app in 2 versions : one demo/light (limitted features) the other full (all features). I have a boolean in code which tells which one is running. They both run as expected in the simulator or on a test device (iOS and Android).

现在我想分发它们.因此我了解到,使用XCode可以定义不同的目标对应于简易版本/完整版本,并带有

Now I want to distribute them. So I read that it was possible with XCode to define different targets corresponding to the light / full versions and with Eclipse it was possible to define the base project as a library and then create 2 projects also corresponding to the light / full versions.

在我开始搞乱我的应用程序项目之前,是否有建议的方法可以实现CodenameOne的目标,可能是通过构建提示来根据构建提示值更改应用程序名称和代码中的布尔值?

Before I start messing around with my app project, is there a recommended way to achieve my goal with CodenameOne maybe via build hints that would change the app name and the boolean inside the code depending on a build hint value ?

编辑19/09/2016(工作方法)

以下是Shai的建议,我遵循的步骤是基于完整版本(如果有人遇到相同的情况)生成一个精简版本:

Following Shai's advices here are the steps I followed to generate a light version based on the full one (in case someone encounters the same case) :

  1. 在您的IDE(Eclipse或其他)下,将基本程序包复制并粘贴到src文件夹中,并将其重命名为com.packageLIGHT.appName (只需将LIGHT附加到程序包名称后,请勿使用下划线或空格,因为稍后将被Apple视为非法字符)

=>所以现在在src文件夹中应该有

=> So now in src folder you should have

src

|-com.packageLIGHT.appName

|- com.packageLIGHT.appName

|-com.package.appName

|- com.package.appName

  1. 然后在com.packageLIGHT.appName中删除MyApp.java以外的所有文件(也称为主文件).在此文件中添加 import com.package.myApp.*;

3.1.(ECLIPSE)在运行/运行配置"菜单中,复制现有配置,并将其粘贴为Simulator_MyAppLIGHT,然后在参数中将其更改为"com.packageLIGHT.myApp.MyApp".

3.1. (ECLIPSE) In "Run/Run Configurations" menu copy the existing config and paste it as Simulator_MyAppLIGHT and in arguments change it to "com.packageLIGHT.myApp.MyApp".

3.2.(NETBEANS)运行/设置项目配置"似乎没有按预期方式工作,因为可能选择的任何配置都会导致相同的默认行为.但是,应用第6步并随后在模拟器中运行项目具有预期的结果.

3.2. (NETBEANS) The "Run/Set Project Configuration" does not seem to work as expected since any configuration that might be selected leads to the same default behaviour. However applying step 6. and running the project in the simulator afterward has the expected result.

现在,您应该可以通过运行不同的配置来运行两个版本.

Now you should be able to run both versions by running the different configurations.

对于iOS(不确定Android是否也需要),您必须生成另一对配置文件.因此,将现有文件移动到iosCerts/FULL中,并使用CN1向导生成轻量"版本设置文件,在此文件中,您可以使用软件包名称来匹配"com.packageLIGHT.myApp".将生成的文件存储在iosCerts/LIGHT中.无需覆盖现有证书(更多信息)证书) .

For iOS (not sure if it is also needed for Android) you have to generate another pair of provisioning files. So move the existing ones in iosCerts/FULL and use CN1 wizard to generate the "light" version provisioning files where you'll adapt the package name to match "com.packageLIGHT.myApp". Store the generated files in iosCerts/LIGHT. There is no need to overwrite the existing certificates (more on certificate here).

最后在"codenameone_settings.properties"中将原始程序包名称替换为"light",以代替 codename1.ios.appid codename1.packageName .另外,根据您要构建的内容,将iOS供应文件更改为iosCerts/LIGHT或FULL.

Finally replace in "codenameone_settings.properties" the original package name with the "light" one for the lines codename1.ios.appid and codename1.packageName. Also change the iOS provisioning files to iosCerts/LIGHT or FULL depending of what you want to build.

现在,当您将Android/iOS版本发送到CN1服务器时,它将根据"codenameone_settings.properties"中编写的程序包构建轻量"版本或完整版本.

Now when you send the Android / iOS build to CN1 server it will build either the "light" version or the full one depending on what package is written in "codenameone_settings.properties".

请注意:如果在步骤6中,则在第469行(android构建)或344行(iOS构建)的build.xml上获取了NullPointerException,该异常处理 certPassword ="$ {codename1.android.keystorePassword} (Android构建)或 appid ="$ {codename1.ios.appid}" (iOS构建),并且您正在Eclipse下使用CN1插件版本1.0.0 20160812,然后 Shai在下面的评论可能值得

Please note : if at step 6. you get NullPointerException on build.xml on line 469 (android build) or 344 (iOS build) which deals with certPassword="${codename1.android.keystorePassword} (android build) or appid="${codename1.ios.appid}" (iOS build) and you're using CN1 plugin version 1.0.0 20160812 under Eclipse then Shai's comment below may be worth it

推荐答案

如果您要使用同一应用程序的2个不同版本,则需要2个不同程序包,因为在商店中唯一定义该应用程序的是应用程序包.有两种常见的实现方法:

If you want 2 distinct versions of the same app then you need 2 distinct packages since the thing that defines the app uniquely in the store is the app package. There are two common ways to do it:

  • 在cn1lib中放置功能并构建两个应用程序
  • 构建一个应用,然后交换 codenameone_settings.properties 文件

第一个应该很清楚,但由于无法运行cn1lib并可能在调试它时遇到问题,因此使用起来可能有些痛苦.

The first one should be pretty clear but might be a bit painful to work with as you can't run the cn1lib and might run into issues debugging it.

第二个实际上很简单.创建应用程序的主版本,然后将软件包添加到演示版本,然后在其中复制主文件.

The second one is actually rather simple. Create the main version of the app then add the package to the demo version and copy the main file there.

要运行演示版本,只需在IDE运行设置"中更改软件包即可.

To run the demo version just change the package in the IDE "run settings".

将您的 codenameone_settings.properties 复制到一个单独的文件中,然后将所有常规软件包名称替换为演示软件包名称.当您要构建演示"版本时,互相替换 codenameone_settings.propeties 文件,显然可以使用脚本来自动执行.

Copy your codenameone_settings.properties to a separate file and just replace all the regular package names to the demo package names. When you want to build the "demo" version replace the codenameone_settings.propeties files with one another, you can automate that with a script obviously.

这篇关于在Codename One中管理我的应用程序的演示版/完整版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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