Archive for the ‘Tuscany - Android’ Category

Extending dalvik’s java framework

Monday, July 27th, 2009

Steps in extending dalvik’s java framework
* cd to the directory containing android sources
* checkout the existing dalvik/ibcore classes under an eclipse java project
* Remove jdk reference from the project’s build path
* From eclipse add wanted classes and resolve dependancies by either removing non needed methods or importing additionnal classes to meet dependancy requirements
* copy the project folder under “/dalvik/libcore/myown” where myown is the folder which contains the source files. Make sure it’s name is lower case and it’s pattern like the following: myown/src/main/java
* Remove all java dirs from dalvik/libcore except those from myown folder. All native, tests, resources, files folders should be maintained. Some freaky tests are performed there like looking for a damn random file (/support/src/test/resources/hyts_Foo.c:/)
* Generate a list of all the packages you want scriptable from your final android.jar. You may want to use this simple package list generator i’ve coded in [1]
* Replace the existing list of packages under /framework/base/android.mk by the one generated above in the libcore_to_document section
* run make, make then update-api and then make sdk. After the update-api, you can already know whether the final android.jar will take in count the sources you added. Simply edit the file at /home/lookouster/Dev/android-sources/frameworks/base/api/current.xml. It contains a full description of all packages and classes.

Commons erros during build:
* missing files at the specified paths: find: `../../dalvik/libcore/sql/src/main/java/java’: No such file or directory. These are the easiest to solve.
* In the case described below you’ll just need to run a make update-api.
******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
1) You can add “@hide” javadoc comments to the methods, etc. listed in the
errors above.

2) You can update current.xml by executing the following command:
make update-api

To submit the revised current.xml to the main Android repository,
you will need approval.
******************************
* You may also encounter javadoc linking problems. You won’t necessarily add all classes from every api you used. Javadoc will then fail referencing via link# tag missing classes, methods or attributes. In such case just remove either the full javadoc comments, or only the javadoc tags.
* Errors in intermediate android stub may occurs. For instance ou can have something like this:
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/javax/xml/bind/annotation/XmlElement.java:15: cannot find symbol
symbol : variable DEFAULT
location: @interface javax.xml.bind.annotation.XmlElement
java.lang.Class type() default javax.xml.bind.annotation.XmlElement.DEFAULT;
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
To solve it, just add .class to the referenced class on the specified error line.
* For other errors you may solve them by removing the full out directory at the root of android sources, and re-run make, make update-api and make sdk.