一个建立两个不同的版本(4.6,4.7和5.0 +以上)的黑莓 [英] One build for two different versions (4.6,4.7 and 5.0+above) in blackberry

查看:157
本文介绍了一个建立两个不同的版本(4.6,4.7和5.0 +以上)的黑莓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要导入Facebook的库黑莓5.0以上,并且不希望导入这些库4.6和4.7。

I want to import facebook libraries for blackberry 5.0 and above and don't want to import those libraries for 4.6 and 4.7.

我试图通过以下链接使用preprocessors 4.7及以上:
http://smartfone-more.blogspot.in/2010/05/coding-for-multiple-blackberry-devices.html

I tried to use preprocessors for 4.7 and above by following below link: http://smartfone-more.blogspot.in/2010/05/coding-for-multiple-blackberry-devices.html

现在及其工作罚款与JDE 4.7,但没有得到预期的结果为5.0。
请找到code低于我尝试:

now its working fine with JDE 4.7 but not getting expected result for 5.0. Please find the code below which i tried:

//#ifdef JDE_4_7_0
import net.rim.device.api.ui.component.ButtonField;
//#else
import net.rim.device.api.ui.component.LabelField;
//#endif
import net.rim.device.api.ui.container.MainScreen;


public class TestScreen extends MainScreen{

        TestScreen(){

                //#ifdef JDE_4_7_0
                ButtonField btn = new ButtonField("Test Button");
                add(btn);
                //#else
                LabelField lbl1 = new LabelField("Test Label 1");

                add(lbl1);
                //#endif
        }
}

由于每code我期待写在其他部分为5.0,如果部分为4.7的结果。
我检查的设备以及JDE两者。

As per the code i am expecting the result written in else part for 5.0 and if part for 4.7. I checked it on device as well as JDE both.

请帮助。

推荐答案

首先,在 JDE_4_7_0 标签是你应该在黑莓项目属性自定义一个标签 - > 编译选项卡 - > preprocessor定义。你可以给它想要的名字。

First of all, the JDE_4_7_0 tag is a custom tag you should define in BlackBerry project properties -> "Compile" tab -> preprocessor defines. You can give it the name you wish.

二,在源文件中,第一行(甚至包声明之前)应该是:

Second, in your source file, the first line (even before package declaration) should be:

//#preprocess

然后,当你要禁用的条件进口,回到preprocessor定义选项卡,并删除 JDE_4_7_0 项。这将使编译器中输入的#else 条款。 BB的Eclipse插件没有检测到操作系统,这是你应该控制工件。

Then, when you want to disable the conditional import, go back to the "preprocessor defines" tab and remove the JDE_4_7_0 entry. That will make the compiler enter the #else clause. The BB plugin for eclipse does not detect the OS, it is all an artifact you should control.

编辑:结果
您将有两套交付,一个为5.0以上,另一个用于4.x的结束BBant工具可以让你一步到位执行编译过程,但编译的产品将是相同的。作为替代方案,您可以:


You'll end with two sets of deliverables, one for 5.0+ and the other for 4.x. BBant tools allows you to perform the compilation process in one step, but the product of the compilation will be the same. As an alternative, you can:


  • 尝试,包括在4.6项目FacebookBlackBerrySDK-vx.x.x.jar和Log4B-vx.x.x.jar(确保它们是preverified)。我能包括这些罐子和编译4.5的项目,但它并不意味着你可以没有任何错误使用它们*。所以...

  • 只有在OS 5.0使用Facebook功能及以上的,通过在运行时用 DeviceInfo.getSoftwareVersion DeviceInfo.getPlatformVersion

  • try to include FacebookBlackBerrySDK-vx.x.x.jar and Log4B-vx.x.x.jar (be sure these are preverified) in a 4.6 project. I was able to include these jars and compile a 4.5 project, but it doesn't mean you can use them with no errors*. So...
  • Use the facebook functionality only in OS 5.0 and above, by detecting it at runtime with DeviceInfo.getSoftwareVersion or DeviceInfo.getPlatformVersion.

使用这种方法,你也许能有4.6+设备,只有那些5.0+将使用FB SDK兼容的单一的应用程序。

Using this approach you might be able to have a single app compatible with 4.6+ devices, and only 5.0+ ones will use fb sdk.

*注意:我不知道为什么,Facebook的黑莓SDK编译为5.0。也许作者只是用较低的OS他在开发机过,谁知道。但是,如果没有测试它,我不能说出它是4.5兼容的,只是罐子是4.5编译。

*NOTE: I don't know why that facebook blackberry sdk is compiled for 5.0. Maybe the author just used the lower OS he had in his development machine, who knows. But without testing it I cannot state it is 4.5 compatible, just that the jar is 4.5 compilable.

这篇关于一个建立两个不同的版本(4.6,4.7和5.0 +以上)的黑莓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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