Friday, December 24, 2010

compile with hidden classes on android

in Android SDK (not AOSP)
sometimes you need to use some 'hidden' classes ( with @hide annotations)

here is how I do it with ant build

first you need to get the whole Android framework jars
it's located in 

copy it to your project/lib/   
(not libs/,  because ant build will include the jars in libs, but here we just need to use it for symbol resolution)

customize your ant build.xml
copy the templates from 
  • for cupcake donut
    • platforms/$API_LEVEL/templates/android_rules.xml
  • for eclair froyo
    • platforms/$API_LEVEL/ant/ant_rules_r2.xml
  • gingerbread 
    • tools/ant/main_rules.xml

  add a path before the compile task <compile>
 <path id="boot.class.ref">
        <fileset dir="./lib">
            <include name="*.jar" />


add a line after <javac>

<compilerarg value="-Xbootclasspath/p:${toString:boot.class.ref}"/$gt;

here I try to update the boot class path with -Xbootclasspath/p option

No comments: