黑莓应用程序 - 导入code-签名的jar到一个应用程序项目 [英] Blackberry Apps - Importing a code-signed jar into an application project

查看:199
本文介绍了黑莓应用程序 - 导入code-签名的jar到一个应用程序项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个库项目黑莓Java开发人员可以导入到他们的项目。它采用保护RIM的API需要将其code-签署,这是我做的事。但是,我不能让我的罐​​进口,并用简单的HelloWorld应用程序的工作。我使用的Eclipse插件黑莓JDE。

编辑:找到解决方案....

因为我发现我删除我试过的事情解决了,只剩下解决办法...

建筑SDK / Libary(使用BB-Ant的工具,无论是在Eclipse或独立)结果
步骤:

A)我必须建立我的SDK的jar作为一个'CLDC应用程序而不是一个'库'结果
    项目,使用BB-Ant的工具。这解决了大部分的我上面有问题。

B)我然后加一个Ant任务采取步骤A产生的JAR和
    做到以下几点:


  • 解压,

  • 编辑清单文件中删除行MicroEdition-简介:MIDP-2.0 - 这行导致一个错误,当您尝试标记要导出的罐子。

  • 然后重新压缩罐子。

请注意:我写了一个砍下BB-ANT-工具Ant脚本来向您展示如何使用
它做上述这两个步骤。该脚本包含下面。

消耗SDK罐子作为最终用户或在自己的项目。结果
然后在罐子集成BB-蚀你做到以下几点:

A)罐子加入中的Buildpath

B)下的排序和导出选项卡上的Java构建路径,选择的jar
出口。这将导致RAPC打造的水罐里的COD文件,这样你只
有一个化学需氧量在末端。

现在,当用户建立这个项目的jar融入决赛
鳕鱼的文件,它很容易传递到手机或SIM卡。

 <?XML版本=1.0编码=UTF-8&GT?;
<,项目名称=XXXXXMobileLib默认为满BASEDIR =>
    <描述>
  说明:构建BBLIB。使用BB-ANT-工具来建立,黑莓标志和包装。
    < /描述>    <的taskdef资源=BB-ANT-defs.xmlCLASSPATH =BIN / BB_ANT_lib / BB-ANT-tools.1.x.x.jar/>
    <物业环境=ENV/>    <! - 用户自定义瓦尔 - >
    <属性名=builderRoot值=。 />
    <属性名=SIG_PASSWORDVALUE =XXXXXXXXX/>
    <属性名=JAVAHOME值=$ {} env.JAVA_HOME/>
    <回声> $ {JAVAHOME}< /回声>
    <属性名=jdehome值=$ {} env.BBJDE_HOME \\/>
    <属性名=模拟值=$ {jdehome} \\模拟器/>
    <属性名=bin的价值=$ {} jdehome \\ BIN/>
    <属性名=releaseBuildOut值=$ {builderRoot} \\ release_out \\/>
    <属性名=srcBuildOut值=$ {builderRoot} \\ srcBuild_out \\/>
    <属性名=JarFixTemp值=$ {builderRoot} \\ tempZip \\/>
    <属性名=buildVersion值=$ {} env.BUILD_VERSION/>    <属性名=APPLICATION_IDVALUE =com.XXXXX.foo.bar $ {} buildVersion/>
    <属性名=APPLICATION_NAMEVALUE =XXXXX BBLIB V $ {} buildVersion/>
    <属性名=application_descVALUE =XXXXX BBLIB V $ {} buildVersion/>
    <属性名=application_vendorVALUE =XXXXX/>
    <属性名=applicaiton_filenameVALUE =XXXXXBBLIB $ {} buildVersion/>
    <属性名=applicaiton_srcs值=$ {} builderRoot / src_in_location //>
    <属性名=zipOutNameVALUE =XXXXX - $ {} buildVersion BBLIB.zip/>
    <属性名=zipOutNameJavadocsVALUE =XXXXX - $ {} buildVersion BBLIBjavadoc.zip/>    <属性名=jde.home位置=$ {} jdehome/>    <! -
    主入口的目标。
     - >
    <目标名称=完全取决于=干净,javadoc的,buildRIM,FixJarManifest,标志,派发/>    <目标名称=FixJarManifest>
        < TSTAMP />
        < MKDIR DIR =$ {} JarFixTemp/>
        <解压SRC =$ {} builderRoot / release_out / $ {} applicaiton_filename的.jar目标=$ {} JarFixTemp/>
        <删除DIR =$ {} builderRoot / release_out / $ {} applicaiton_filename的.jar/>
        <! - 出于某种原因RAPC把此行到清单文件,但是当你尝试它打破了JDE插件
             设置出口的罐子。让这样的错误项目{0}缺少的......
             为了避免在清单中的空行,我只是注入新的属性生成时 - >
        <更换文件=$ {} JarFixTemp /META-INF/MANIFEST.MF令牌=MicroEdition-简介:MIDP-2.0VALUE =制作时间:$ {DSTAMP} - $ {} TSTAMP/>
        <拉链destfile =$ {} builderRoot / release_out / $ {} applicaiton_filename的.jar
            BASEDIR =$ {} JarFixTemp
        />
        <删除DIR =$ {} JarFixTemp/>
    < /目标与GT;    <! - 清理在OUTDIR任何现有文件 - >
    <目标名称=干净>
        <删除>
            <文件集DIR =$ {} releaseBuildOut包括=**/>
        < /删除>
    < /目标与GT;
    <! - 生成的Javadoc - >
    <目标名称=的javadoc>
        < javadoc的访问=公DESTDIR =$ {} releaseBuildOut / JavaDoc中作者=真版本=真的使用=真defaultexcludes =YESexcludepackagenames =。net.rim *WINDOWTITLE = foo_bar这样的名称>
            <文件集DIR =$ {} applicaiton_srcs / XXXXXMobileLib>
                <包括姓名=SRC / ** / * java的。/>
            < /文件集>
        < / javadoc的>
        <拉链destfile =$ {releaseBuildOut} / $ {} zipOutNameJavadocsBASEDIR =$ {} releaseBuildOut / JavaDoc中/>
        <删除DIR =$ {} releaseBuildOut / JavaDoc中/>
    < /目标与GT;    <目标名称=buildRIM描述=构建项目>
        < RAPC jdehome =$ {} jdehomeJDKHOME =$ {} JAVAHOMEDESTDIR =$ {} releaseBuildOut输出=$ {} applicaiton_filename安静=false的>
            &所述;! - 建筑作为CLDC应用程序了,因此它可以被包装与我们的最终鳕鱼,作为一个单一的鳕鱼 - >
            < JDP TYPE =CLDC
                 标题=$ {} application_desc
                 供应商=$ {} application_vendor
                 版本=$ {} buildVersion
                 说明=$ {} application_desc
                 参数=
                 systemmodule =假
                 runonstartup =假
                 startuptier =7
                 ribbonposition =0>
            < / JDP>
            <&SRC GT;
                <文件集DIR =$ {} applicaiton_srcs / MobileLib>
                    <包括姓名=SRC / ** / * java的。/>
                < /文件集>
            < / src目录>
        < / RAPC>
    < /目标与GT;    <目标名称=符号=取决于清洁,buildRIM>
        < sigtool密码=$ {} SIG_PASSWORD>
            <文件集DIR =$ {} releaseBuildOut包括=*鳕鱼。/>
        < / sigtool>
        <回声>在signingtool的日志文件的内容:LT; /回声>
        <回声文件=LOGFILE.TXT/>
    < /目标与GT;    <! - 生成和分发罐子 - >
    <目标名称=派发取决于=buildRIM描述=生成分配>
        < ALX DESTDIR =$ {} releaseBuildOut文件名=$ {} applicaiton_filename的.alx>
            <应用ID =$ {} APPLICATION_IDNAME =$ {} APPLICATION_NAME>
                < codset>
                    <文件集DIR =$ {} releaseBuildOut包括=*鳕鱼。/>
                < / codset>
            < /用途>
        < / ALX>        <! - 创建释放拉链 - >
        <删除文件=$ {releaseBuildOut} / $ {} zipOutName/>
        <拉链destfile =$ {releaseBuildOut} / $ {} zipOutName>
            <! - 拉上了BB罐子,然后将其分配 - >
            < zipfileset DIR =$ {} releaseBuildOut包括=** / *罐子。/>
        < /拉链>        <招todir =$ {} releaseBuildOut / UNUSED_BUILD_OUTPUT_FILES /><! - 移动不需要的文件,留下背后拉链 - >
            <文件集DIR =$ {} releaseBuildOut>
                <包括姓名= /&GT** / *。*;
                <** / *拉链排除名称= />
            < /文件集>
        < /移动>
    < /目标与GT;
< /项目>


解决方案

我用你的脚步急症室; B到创建一个'库' - 感谢。
黑莓最新的Eclipse插件(1.3.0.201102031007-19)具有黑莓|包项目命令。我用这个来创建jar文件(它把它放在一个成果文件夹中的项目)。

我再变表现为你建议删除MIDP行(这显然是一个已知的bug)。最后,我跟着步骤添加和部署的lib到我的项目。 (这,顺便说一句,都是添加横幅/广告库中相同的步骤 - 很容易)

我也有一个独立/外部生成脚本,使用BB-ANT-工具处理。我最近添加了外部库罐子功能,以适应这一点。但是,使用Eclipse中的新功能使我的问题,如果我要保持我的命令行构建脚本作为GUI现在这样对我来说。

对我来说,关键是我的图书馆项目的构建切换到黑莓程序(例如CDLC应用程序)按照您的指示。有了它设置为库我得到了掏空的错误。

感谢您的帖子。

I'm working on a library project that Blackberry Java developers can import into their projects. It uses protected RIM APIs which require that it be code-signed, which I have done. But, I can't get my Jar imported and working with a simple helloWorld app. I'm using the eclipse plug-in Blackberry-JDE.

EDIT : Solution found....

since I found the solution I removed the things I've tried, leaving only the solution ...

BUILDING THE SDK/Libary (use BB-ANT-TOOLS, either in eclipse or standalone)
steps:

A) I had to build my SDK's jar as an 'cldc' application not as a 'library'
project, using BB-ANT-TOOLS. This solved most of the issues I had above.

B) I then added an ANT task to take the resulting JAR from step A and do the following:

  • unzip it,
  • edit the manifest file to remove the line "MicroEdition-Profile: MIDP-2.0" -- This line causes an error when you try to mark the jar for export.
  • then re-zipped the jar.

NOTE: I wrote a chopped down BB-ANT-TOOLS ant script to show how you could use it to do these two steps above. The script is included below.

Consuming the SDK jar as an end-user or in your own project.
Then to integrate the jar in bb-eclipse you do the following:

A) Add the jar to the BuildPath

B) under "Java Build Path" on the "Order and Export" tab, Select the jar for export. This causes rapc to build the jar into the COD file, so that you only have one COD at the end.

now when a user builds this project the jar become integrated into the final cod file, and it's very easy to deliver to the phone or sim.

<?xml version="1.0" encoding="UTF-8"?>
<project name="XXXXXMobileLib" default="full" basedir=".">
    <description>
  Description: Builds the BBLIB. Uses bb-ant-tools to build, sign and package for blackberry. 
    </description>

    <taskdef resource="bb-ant-defs.xml" classpath="BIN/BB_ANT_lib/bb-ant-tools.1.x.x.jar" />
    <property environment="env" />

    <!-- User defined Vars -->
    <property name="builderRoot" value="." />
    <property name="SIG_PASSWORD" value="XXXXXXXXX" />
    <property name="javaHome" value="${env.JAVA_HOME}" />
    <echo>${javaHome}</echo>
    <property name="jdehome" value="${env.BBJDE_HOME}\" />
    <property name="simulator" value="${jdehome}\simulator" />
    <property name="bin" value="${jdehome}\bin" />
    <property name="releaseBuildOut" value="${builderRoot}\release_out\" />
    <property name="srcBuildOut" value="${builderRoot}\srcBuild_out\" />
    <property name="JarFixTemp" value="${builderRoot}\.tempZip\" />
    <property name="buildVersion" value="${env.BUILD_VERSION}" />

    <property name="application_id" value="com.XXXXX.foo.bar.${buildVersion}" />
    <property name="application_name" value="XXXXX BBLIB v${buildVersion}" />
    <property name="application_desc" value="XXXXX BBLIB v${buildVersion}" />
    <property name="application_vendor" value="XXXXX" />
    <property name="applicaiton_filename" value="XXXXXBBLIB${buildVersion}" />
    <property name="applicaiton_srcs" value="${builderRoot}/src_in_location/" />
    <property name="zipOutName" value="XXXXX-${buildVersion}BBLIB.zip" />
    <property name="zipOutNameJavadocs" value="XXXXX-${buildVersion}BBLIBjavadoc.zip" />

    <property name="jde.home" location="${jdehome}" />

    <!-- 
    MAIN ENTRY TARGET. 
    -->
    <target name="full" depends="clean,javadoc,buildRIM,FixJarManifest,sign,distribute" />

    <target name="FixJarManifest">
        <tstamp/>
        <mkdir dir="${JarFixTemp}"/>
        <unzip src="${builderRoot}/release_out/${applicaiton_filename}.jar" dest="${JarFixTemp}"/>
        <delete dir="${builderRoot}/release_out/${applicaiton_filename}.jar"/>
        <!-- For some reason rapc puts this line into the manifest file, but it breaks the JDE plug-in when you try to
             set the jar for export.  Giving an error like this "Project {0} missing......" 
             To avoid having an empty line in the manifest, Im just injecting a new attribute BuildTime-->
        <replace file="${JarFixTemp}/META-INF/MANIFEST.MF" token="MicroEdition-Profile: MIDP-2.0" value="Build-Time: ${DSTAMP}-${TSTAMP}"/>
        <zip destfile="${builderRoot}/release_out/${applicaiton_filename}.jar"
            basedir="${JarFixTemp}"
        />
        <delete dir="${JarFixTemp}"/>
    </target>

    <!-- Cleanup any existing files in the outdir -->
    <target name="clean">
        <delete>
            <fileset dir="${releaseBuildOut}" includes="**" />
        </delete>
    </target>


    <!-- Generate the Javadocs -->
    <target name="javadoc">
        <javadoc access="public" destdir="${releaseBuildOut}/JavaDocs" author="true" version="true" use="true" defaultexcludes="yes" excludepackagenames="net.rim.*" windowtitle="FOO_BAR">
            <fileset dir="${applicaiton_srcs}/XXXXXMobileLib">
                <include name="src/**/*.java" />
            </fileset>
        </javadoc>
        <zip destfile="${releaseBuildOut}/${zipOutNameJavadocs}" basedir="${releaseBuildOut}/JavaDocs" />
        <delete dir="${releaseBuildOut}/JavaDocs"/>
    </target>

    <target name="buildRIM" description="Builds Project">
        <rapc jdehome="${jdehome}" jdkhome="${javaHome}" destdir="${releaseBuildOut}" output="${applicaiton_filename}" quiet="false">
            <!-- Building as a cldc applicaiton, so it can be packaged up with our final cod, as a single cod -->
            <jdp type="cldc" 
                 title="${application_desc}" 
                 vendor="${application_vendor}" 
                 version="${buildVersion}" 
                 description="${application_desc}" 
                 arguments="" 
                 systemmodule="false" 
                 runonstartup="false" 
                 startuptier="7" 
                 ribbonposition="0">
            </jdp>
            <src>
                <fileset dir="${applicaiton_srcs}/MobileLib">
                    <include name="src/**/*.java" />
                </fileset>
            </src>
        </rapc>
    </target>

    <target name="sign" depends="clean,buildRIM">
        <sigtool password="${SIG_PASSWORD}">
            <fileset dir="${releaseBuildOut}" includes="*.cod" />
        </sigtool>
        <echo>Contents of the signingtool's logfile: </echo>
        <echo file="LogFile.txt" />
    </target>

    <!-- build and distribute the jar -->
    <target name="distribute" depends="buildRIM" description="generate the distribution">
        <alx destdir="${releaseBuildOut}" filename="${applicaiton_filename}.alx">
            <application id="${application_id}" name="${application_name}">
                <codset>
                    <fileset dir="${releaseBuildOut}" includes="*.cod" />
                </codset>
            </application>
        </alx>

        <!-- Create release zip -->
        <delete file="${releaseBuildOut}/${zipOutName}" />
        <zip destfile="${releaseBuildOut}/${zipOutName}">
            <!-- zip up the BB jar and drop it for distribution -->
            <zipfileset dir="${releaseBuildOut}" includes="**/*.jar" />
        </zip>

        <move todir="${releaseBuildOut}/UNUSED_BUILD_OUTPUT_FILES/"><!-- move unwanted files, leaving the zip behind -->
            <fileset dir="${releaseBuildOut}">
                <include name="**/*.*"/>
                <exclude name="**/*.zip"/>
            </fileset>
        </move>
    </target>
</project>

解决方案

I have used your steps A & B to create a 'library' - thanks. The latest Eclipse plugin for Blackberry (1.3.0.201102031007-19) has a "Blackberry | Package Project" command. I used this to create the jar file (it put it in a 'deliverables' folder in the project).

I then changed the manifest as you suggest to remove MIDP line (which apparently is a known bug). Finally, I followed the steps to add and deploy the lib to my project. (These, btw, are the same steps to adding the Banner / advertising library - very easy.)

I too have a stand-alone / external build script process that uses bb-ant-tools. I recently added the 'external library jar' feature to accommodate this. But using the new feature in Eclipse makes me question if I need to maintain my command-line build scripts as the GUI now does it for me.

The key for me was to switch the build of my library project to a "Blackberry Application" (e.g. CDLC app) as per your instructions. With it set as a 'Library' I was getting that "eviscerated" error.

Thanks for your post.

这篇关于黑莓应用程序 - 导入code-签名的jar到一个应用程序项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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