Problem using external APIS

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Problem using external APIS

Postby Helios » Wed Feb 18, 2009 10:07 pm

Hi everyone, I have the following problem. I am trying to create an application that uses external java classes which I can build correctly in a separate eclipse java project. The problem is, that in order to build this classes I have to import the jaxb-api.jar which causes a building problem when I import it to my android project. To solve this, I am trying to use the "retrotranslator" which as I understand using compiled java classes generates a .jar file which can be used on an android application. My problem is that I tried using this tool but I couldn't generate the .jar file. Does any one knows how to do this? (I have already read the retrotranslator manual I mean something less general)

I have read that you can use a build.xml file like the one below, but I don't understand how to do this.

Thanks in advance.


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <!--
  2. You may freely edit this file. See commented blocks below for
  3. -->
  4. <!-- some examples of how to customize the build. -->
  5. <!--
  6. (If you delete it and reopen the project it will be recreated.)
  7. -->
  8. <project name="JAXB_Android" default="default" basedir=".">
  9. <description>Builds, tests, and runs the project JAXB Android.</description>
  10. <import file="nbproject/build-impl.xml"/>
  11. <!--
  14.    There exist several targets which are by default empty and which can be
  15.    used for execution of your tasks. These targets are usually executed
  16.    before and after some main targets. They are:
  18.      -pre-init:                 called before initialization of project properties
  19.      -post-init:                called after initialization of project properties
  20.      -pre-compile:              called before javac compilation
  21.      -post-compile:             called after javac compilation
  22.      -pre-compile-single:       called before javac compilation of single file
  23.      -post-compile-single:      called after javac compilation of single file
  24.      -pre-compile-test:         called before javac compilation of JUnit tests
  25.      -post-compile-test:        called after javac compilation of JUnit tests
  26.      -pre-compile-test-single:  called before javac compilation of single JUnit test
  27.      -post-compile-test-single: called after javac compilation of single JUunit test
  28.      -pre-jar:                  called before JAR building
  29.      -post-jar:                 called after JAR building
  30.      -post-clean:               called after cleaning build products
  32.    (Targets beginning with '-' are not intended to be called on their own.)
  34.    Example of inserting an obfuscator after compilation could look like this:
  36.        <target name="-post-compile">
  37.            <obfuscate>
  38.                <fileset dir="${build.classes.dir}"/>
  39.            </obfuscate>
  40.        </target>
  42.    For list of available properties check the imported
  43.    nbproject/build-impl.xml file.
  46.    Another way to customize the build is by overriding existing main targets.
  47.    The targets of interest are:
  49.      -init-macrodef-javac:     defines macro for javac compilation
  50.      -init-macrodef-junit:     defines macro for junit execution
  51.      -init-macrodef-debug:     defines macro for class debugging
  52.      -init-macrodef-java:      defines macro for class execution
  53.      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  54.      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  55.      run:                      execution of project
  56.      -javadoc-build:           Javadoc generation
  57.      test-report:              JUnit report generation
  59.    An example of overriding the target for project execution could look like this:
  61.        <target name="run" depends="JAXB_Android-impl.jar">
  62.            <exec dir="bin" executable="launcher.exe">
  63.                <arg file="${dist.jar}"/>
  64.            </exec>
  65.         </target>      
  66.    Notice that the overridden target depends on the jar target and not only on
  67.    the compile target as the regular run target does. Again, for a list of available
  68.    properties which you can use, check the target you are overriding in the
  69.    nbproject/build-impl.xml file.
  72. -->
  73. <target name="-post-compile" depends="-do-compile">
  74. <property name="original-classes" value="${build.classes.dir}/original-classes"/>
  75. <property name="outdir-classes" value="${build.classes.dir}"/>
  76. <move todir="${original-classes}">
  77. <fileset dir="${outdir-classes}"/>
  78. </move>
  79. <mkdir dir="${outdir-classes}"/>
  80. <taskdef name="retrotranslator" classname="net.sf.retrotranslator.transformer.RetrotranslatorTask">
  81. <classpath>
  82. <fileset dir="Retrotranslator-1.2.6-bin" includes="*.jar"/>
  83. </classpath>
  84. </taskdef>
  85. <retrotranslator target="1.5" embed="support" reflection="safe" stripannot="true" srcdir="${original-classes}" destdir="${outdir-classes}"/>
  86. </target>
  87. </project>
Parsed in 0.002 seconds, using GeSHi
Junior Developer
Junior Developer
Posts: 23
Joined: Sat Jan 17, 2009 7:11 am


Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 3 guests