Building Android runtimes

4 posts / 0 new
Last post
overfl0w
overfl0w's picture
Offline
Mobile Conjurer
Joined: 12 Jun 2010
Posts:
Building Android runtimes

I am trying to develop an extension for MoSync. I have followed the tutorial and have successfully implemented the extension in the emulator runtimes, where it works like a charm!

However, I am stuck trying to build the Android runtimes. Any guidelines / tutorials on how to do so?

Thanks

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anders Malm
andersmalm's picture
Offline
Mobile Conjurer
Joined: 28 Aug 2008
Posts:

Hi overfl0w!

To build the runtime you can do the following:

I assume you are running a version of MoSync is no longer than 4 weeks old.

1. You have to download both the latest Android SDK and the Android NDK ( I'm using ndk-r4b ).

2. In the SDK you have to run the SDK Setup.exe and download, atleast, the SDK for cupcake 1.5

3. Make a copy of trunk/tools/RuntimeBuilder/Settings.rb.example as trunk/tools/RuntimeBuilder/Settings.rb ( unless you already has done so ). You have to set the paths android_sdk and android ndk. On my computer it looks like:

:android_sdk => "C:/Android/android-sdk-windows",
:android_ndk => "C:/Android/android-ndk-r4b",

4. Download and install cygwin, atleast version 1.7. You must install awk and make. Cygwin is needed by the Android NDK to build the native c++ based MoSync core.

5. The easiest way to test if you can build an android runtime is to build it from command line. Go to the folder trunk/tools/RuntimeBuilder/ and execute:
RuntimeBuilder.rb Settings.rb android c:\MoSync\profiles\runtimes\android\1\
For this to work you must have installed MoSync on your computer since the last argument is the path to where the config.h and configD.h files are located. This way you can build an application using your new runtime directly in the MoSync IDE.

When building an extension in Android you have to write it in both C++ and Java. The core in MoSync is running inside a library so that library has to have your new functions in it. Check out the files in /runtimes/cpp/platforms/android . SyscallImpl.cpp is where most syscalls are implemented. Those syscalls more or less, only calls Java methods. Those are are stored in /runtimes/java/platforms/androidJNI/src . MoSync allocates a direct ByteBuffer on the Java side which is then used as memory for MoSync applications. The code isn't that well documented but I hope you will be able to follow it and see what it does.

If you have any questions, just send them to me and I will help you!

overfl0w
overfl0w's picture
Offline
Mobile Conjurer
Joined: 12 Jun 2010
Posts:

Thanks for your reply.

I have gone through all the steps you mentioned and successfully built the runtimes. Next, I made a simple change to the runtimes and re-built them (I added a maIOCtl_maSyscall case in the maIOCtl switch, which posts an event). As far as I could tell there were no build errors. Then, I re-built the user libraries.

Finally, I tried re-building my Mosync project, specifying Google Nexus as a target. I got no compile or link errors, but at the end of the build process I got the following error (copied from console):

java -jar c:\MoSync\bin\android\dx.jar --dex --patch-string com/mosync/java/android com/mosync/app_FlyBed "--output=C:\Myproject\Output\Release\android\1\classes.dex" "C:\Myproject\Output\Release\android\1\classes"

no classfiles specified


java -jar c:\MoSync\bin\android\apkbuilder.jar "C:\Myproject\Output\Release\android\1\test_unsigned.apk" -u -z "C:\Myproject\Output\Release\android\1\resources.ap_" -f "C:\Myproject\Output\Release\android\1\classes.dex" -nf "C:\Myproject\Output\Release\android\1\addlib"

C:\Myproject\Output\Release\android\1\classes.dex does not exists!

 

Do I have to do anything else, or maybe there was an error building the runtimes that I did not see?

 

Anders Malm
andersmalm's picture
Offline
Mobile Conjurer
Joined: 28 Aug 2008
Posts:

I think it sounds like there has been a build error in the Java side when you build the runtime. Run the RuntimeBuilder step again and verify the output again. It's a little bit 'hackish' so it can in some cases say that it succeeded even though it didn't. It's made to work on a cleaned checked out version of the source code when we build packages. I will fix that script.

But please verify that output, and if you have doubts you can send the contents from the command window to me at eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%61%6e%64%65%72%73%40%6d%6f%73%79%6e%63%2e%63%6f%6d%22%3e%61%6e%64%65%72%73%40%6d%6f%73%79%6e%63%2e%63%6f%6d%3c%2f%61%3e%27%29%3b')) and I can look at it.