rexnjc / java-ide-droid

Automatically exported from code.google.com/p/java-ide-droid
0 stars 0 forks source link

aapt integration #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
aapt needs to be integrated.
Sincs aapt is a C++ program, we will need to make a native library and 
integrate this library.

Original issue reported on code.google.com by tom.ar...@gmail.com on 20 May 2011 at 12:49

GoogleCodeExporter commented 8 years ago
love this project. this app would be one of my most important, if aapt is 
integrated! but good work so far!

Original comment by br0kendr...@googlemail.com on 7 Jun 2011 at 10:14

GoogleCodeExporter commented 8 years ago
I have made a first little NDK demo:
(see HelloAndroid_NDK in Downloads)

Now, I'll look into that aapt lib!

Original comment by tom.ar...@gmail.com on 9 Jun 2011 at 9:48

GoogleCodeExporter commented 8 years ago
Hmm... the look at the aapt code confirms that my C/C++ is too limited to 
handle this properly :-(

- How do we redirect stdout / stderr to a string? Do we need to replace all 
fprintf with sprintf or is there a better way?
- Is there a dynamically growing buffer in C++ like Java's StringBuffer?
  If not, we'll need to check for buffer overflows
- aapt depends on external libs like expat and zlib. 
  Do we need to port them all or are they already available on the Android device?
- Can we return more than 1 value from the JNI method?
  I would like to return an errorcode (int), the stderr string and the stdout string

Here's the link to the source code:
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=tools/aap
t;h=89c06bbbe971d68486c39fa2ef5000399032f1e9;hb=HEAD

Original comment by tom.ar...@gmail.com on 10 Jun 2011 at 6:01

GoogleCodeExporter commented 8 years ago
it's very much easier, if we write an own aap-part in java, not?
is there a method to create R.java manually?
what are the other things, that aapt has to do?

Original comment by br0kendr...@googlemail.com on 10 Jun 2011 at 9:17

GoogleCodeExporter commented 8 years ago
I have also thought about porting aapt to Java, but thought it more complicated 
than doing the native lib.

> what are the other things, that aapt has to do?

* appt creates the R.java
  this is probably not very difficult
* It compiles resources, mainly (only?) xml files into a binary format. 
  I have no idea how this is done exactly. We'd have to check the source for this. 
* It also does something with the images
  it seems it only optimizes them, because the images inside an APK can still be
  viewed with an image viewer.
* It creates an APK file with the compiled resources, images and raw 
(unchanged) 
  items (e.g. html files) in it.
  This is an easy thing, because an APK file is just a ZIP file.

If we were to port aapt to Java, I would recommend to integrate the apkbuilder 
as well, because in JavaIDEdroid the apkbuilder also does not do much else than 
adding items to the APK file. It adds the classes.dex and further items like 
jar files, native libs, raw resources, etc. On Windows, apkbuilder also signs 
the APK, but this does not work in JavaIDEdroid where the signing is done with 
the ZipSigner lib.

Tom

Original comment by tom.ar...@gmail.com on 10 Jun 2011 at 10:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Tom, i have downloaded aapt source and will try and look at it to night, do you 
have some sample arguments that are passed to aapt? I will need them to test it.

I already have zlib ported to android i have not heard of the other, but if its 
already in c it should be straight forward.

As for returning more then one variable no u can not. Its like any function 
only one variable at a time. Granted u could return a string[] holding your 
values. But in this case it would probably be better just to print the values 
out to the logcat while in c then pass them back to java.

As for a dynamic array the best for this in c is a Vector of strings.

Original comment by Jug6ern...@gmail.com on 10 Jun 2011 at 5:43

GoogleCodeExporter commented 8 years ago
Download the sample app HelloAndroid_1-0.zip from the download area.
There, you'll the aapt.bat which we want to replace with the aapt module and a 
aapt.bsh BeanShell script.

>As for returning more then one variable no u can not.

I once made a JNI program for Window Mobile. There, I returned an integer and 
wrote the error message from the JNI program directly back into a public String 
of the Java program. This is probably not a very clean way, but would it work?

Tom

Original comment by tom.ar...@gmail.com on 10 Jun 2011 at 7:10

GoogleCodeExporter commented 8 years ago
I have added the aapt source files and the source files of the external libs 
for aapt to the SVN.

I have created a shared lib for zlib but when I wanted to compile libpng (which 
needs zlib) zlib was not found.

Maybe I need to make a static library for zlib (instead of a shared lib) and 
then add this static lib to the Android.mk of libpng?

Tom

Original comment by tom.ar...@gmail.com on 20 Jul 2011 at 9:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have built aapt and all its depending libraries as an Android >=2.3 ARM 
console application! 

The complete aapt package can be downloaded separately from the SVN:
svn/trunk/jni/materials/aapt-port-android_1-0-0.zip

Can someone with a rooted device please test this executable?
My device is not rooted, and it is still 2.2.1, so I cannot test myself.

Thanks
Tom

Original comment by tom.ar...@gmail.com on 16 Aug 2011 at 2:12

GoogleCodeExporter commented 8 years ago
aapt has been integrated in version 1.0.0

Original comment by tom.ar...@gmail.com on 22 Aug 2011 at 7:04