Showing posts with label ant. Show all posts
Showing posts with label ant. Show all posts

Friday, July 29, 2011

custom android build.xml

之前要改android的build.xml時
通常先在我自己的build.xml最後那 改 setup import="false"
然後再去把SDK裡的template copy出來
加到build.xml的後面

不過今天發現
可以不用那麼麻煩
import="false"也不用加
只要先把template裡面的你想要改的target  copy出來
貼到你的build.xml上
再自己改想要改的東西  就可以了

inspired by class loading example http://code.google.com/p/android-custom-class-loading-sample/

Friday, January 14, 2011

ant build to include jars

在android上
用ant build時 他會自動幫你把libs/裡的jar包到dex裡面

可是在最近的sdk Gingerbread一樣用ant build
發現不行了

看一看ant的build  $SDK/tools/ant/main_rules.xml
原來是在 dex-helper裡
apply  dx的tag裡 新的把include jar的tag拿掉了
所以把<fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />加上就好了

不過話說我要用mydroid build時
又發現他的resources.arsc又不一樣了
http://allstarschh.blogspot.com/2010/10/resourcesarsc.html

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 
mydroid/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar

1:
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)

2: 
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

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

then

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