View unanswered posts | View active topics



Reply to topic  [ 13 posts ] 
Multi-Platform template for haXe (Android, Flash, webOS) 
Author Message
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
Hi everyone!

I just made a project template for multi-platform development, using haXe. It supports Palm webOS, Android and Flash, compiled off the same source code. The template handles much of the difference between each targets build processes, so writing and compiling is a quick and easy process.

http://www.eclecticdesignstudio.com/cod ... roject.fdz


Please let me know if you're interested in trying it out, and I can try to explain more thoroughly what it is required to compile for either Palm or Android.


Wed Feb 09, 2011 2:11 pm
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
I have compile error:

Building projectname
haxe -cp Source -swf9 D:/workspace/haxe/projectname/Export/Flash/projectname.swf -swf-header 320:480:30:FFFFFF -swf-version 10 -debug -main .projectname

Error : Invalid class name .projectname
Build halted with errors (haxe.exe).


Why you add dot do project name?


Thu Feb 10, 2011 6:25 am
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
Hi Cintian,

Try updating to the latest version of the template, then make sure you complete the package name option when you create your new project ... something like this:

com.testing.test


Once you're able to build for Flash, I can help you with the additional tools you'll need to install if you want to compile for either Android or webOS


Thu Feb 10, 2011 6:39 am
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
Building bleble
haxe -cp Source -swf9 D:/workspace/haxe/bleble/Export/Flash/bleble.swf -swf-header 320:480:30:FFFFFF -swf-version 10 -debug -main com.testing.test.bleble

Error : Invalid class name com.testing.test.bleble
Build halted with errors (haxe.exe).


I use FD4 perhaps it is a problem?
I will try at home on FD3.

You can add some small tutorial what needs in order to compile up to the android ?


Last edited by Cintian on Thu Feb 10, 2011 7:30 am, edited 1 time in total.



Thu Feb 10, 2011 7:14 am
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
I was scratching my head there for a minute.

I forgot that haXe enforces lowercase package names and capitalized class names.

Try and create a new project one more time. Try "Bleble" as the project name, and "com.testing.test" as the package


Thu Feb 10, 2011 7:29 am
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
They are compiling.
True, the Name of the class must begin from a capital letter in haxe.

Great thanks for the help. :D


Thu Feb 10, 2011 7:37 am
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
If you want to get started with webOS or Android, these threads should help:

http://developer.palm.com/distribution/ ... 70&t=11015
http://developer.palm.com/distribution/ ... =70&t=8499


The first link includes information about how to do certain things in haXe, and provides a brief overview for someone who is new to the process. The second link includes instructions for working with webOS, but also includes some instructions that are needed for Android development.

webOS development requires a CodeSourcery GNU toolchain and the Palm SDK. That's all -- it's really easy.

Android is more complicated, but I'll try and walk through the steps.

For the template to work for either platform, download the hxcpp-webos libraries onto your machine, and configure haXe to point to those versions of hxcpp and nekonme. The second link above includes some instructions for how to do that.

Next, you'll need to download the following for Android development:

  • Android SDK
  • Android NDK r5
  • Apache ANT
  • Java JDK

Unfortunately, ANT is very picky about paths, so you may need to put these all in directories without spaces in them. I put it all in a "Development" folder, like "E:\Development\Android\NDK", etc.

Then you need to run SDK Manager and install these packages:

  • Android SDK Tools
  • Android SDK Platform-tools
  • SDK Platform Android 2.1-update1, API7
  • Google APIs by Google, Inc., Android API 7

You can also install other platform and API versions if you want to. API 7 should be the one I'm using currently in the template.

If you have everything downloaded, you'll then have to configure a bunch of environment variables. Right-click "Computer", go to Properties > Advanced System Settings > Environment Variables, and configure the following variables, using the appropriate values for your machine:

  • ANDROID_NDK_ROOT (ie E:\Development\Android\NDK)
  • ANT_HOME (ie E:\Development\Ant)
  • JAVA_HOME (ie E:\Development\Java\jdk1.6.0_23)

... then add the following values to your PATH variable (or create it if it doesn't exist):

  • %JAVA_HOME%/bin;
  • %ANT_HOME%/bin;
  • E:\Development\Android\SDK\platform-tools; (wherever this is installed)
  • E:\Development\Android\SDK\tools; (wherever this is installed)

You can test everything out by opening a command line, and making sure these commands all work:

  • ant
  • adb
  • javac

If you made it this far, I think the template should work for you. For some reason on my machine, ANT thought JAVA_HOME was equal to a JRE on my machine. It totally wasn't. I eventually had to copy all of the JDK files into the JRE directory ... hopefully you won't have to do the same.

The template is designed so you can hit F5 or Ctrl+Enter to build, and it will compile and push it to the phone. It'll also run it on webOS, but Android doesn't seem to support that. Anything you put in the Export/Flash directory will be copied locally into your C++ applications, so use relative file paths and it will work for all three compile targets.

There is one caveat to this, however. Instead of extracting files, like other platforms, Android keeps applications inside of their APK file while on the phone. This creates huge headaches for trying to access supporting assets. This morning it wasn't possible unless you put the files on your external storage drive yourself, but I've worked out a system so far that will work so long as files are not located in sub-directories. I'm copying files out of the package into an internal storage directory on the device, but the directory doesn't appear to support sub-directories. I'm going to try and work out a system that will allow you to still access files as if they were in a sub-directory, but its not here yet.

Let me know if you hit roadblocks, or if it works!


Thu Feb 10, 2011 8:06 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
I think a very basic example project would help getting started, like Jess Warden's Balloon Pop Corona test for instance.


Thu Feb 10, 2011 9:32 am
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
On my home PC

progress: [|||| ] 90%

- ant [work]
- adb [work]
- javac [work]
- compilink android template [error]

error:

Building AndroidMultiplatformCppInHaxe (Android)
haxe -cp Source -lib nme -lib hxcpp -swf D:/Haxe/projects/AndroidMultiplatformCppInHaxe/obj/Android -swf-header 320:480:30:FFFFFF -swf-version 6 -debug -D android -main pl.cintian.AndroidMultiplatformCppInHaxe --remap flash:nme

C:\Motion-Twin\haxe\lib\nme/2,0,1/nme/Loader.hx:14: characters 11-33 : unsupported platform
Build halted with errors (haxe.exe).


In template as default was :
Project->Propertis->Platform->target::Flash Player 6

if change target to Flash Player 9 or 10 i have next error:
Sys_error("D:/Haxe/projects/AndroidMultiplatformCppInHaxe/obj/Android: Permission denied")
Build halted with errors (haxe.exe).


What now ? ;)


Thu Feb 10, 2011 4:32 pm
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
Okay, cool.

That's strange that permission is denied. When you compile, it runs a series of batch processes to compile, package and install the application.

Here's an idea:

Try closing FlashDevelop, then right-clicking on its icon and selecting "Run as Administrator". Perhaps that will fix the error? If not, you can also try to edit ../Export/Android/scripts/package.bat, and change the value of STAGING_DIR to a different folder on your machine. The project is set up to use a subdirectory inside of ../obj/ since the folder is used by FlashDevelop by default, and is usually hidden. If running as Administrator doesn't work, telling the batch process to use a different folder for staging should help.


Thu Feb 10, 2011 6:35 pm
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
Still I have the same error.

But if I will do all from the package.bat file in cmd, it works.

BUILD SUCCESSFUL
Total time: 12 seconds


Thank you very much for your help and the devoted time. :)


Fri Feb 11, 2011 7:50 am
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
Hey,

Just wanted to post to say that the resource loading is now working. If you try to load assets using ByteArray.readFile, it can now pull files out of the Android APK.

Anything you put in ../Export/Flash/ will be available through relative paths for any compile target. For example, if you put an image file at ../Export/Flash/images/MyImage.png, you could access it from haXe like this:

Code:
#if flash

var loader:Loader = new Loader ();
loader.load (new URLRequest ("images/MyImage.png"));
addChild (loader);

#elseif cpp

var bitmap:Bitmap = new Bitmap (BitmapData.loadFromBytes (ByteArray.readFile ("images/MyImage.png")))
addChild (bitmap);

#end



Does that mean that you are able to compile, or is it only halfway working? Which OS/version are you using?


Fri Feb 11, 2011 3:11 pm
Profile WWW
Member

Joined: Thu Aug 05, 2010 8:12 am
Posts: 17
Location: Polish
Reply with quote
Hello

I still cant compile from ProjectName (Android). Have the sames problem.

To compilin project I:
- copying all from ProjectName\obj\Android to ProjectName\Export\Android
- create compile.bat
- running compile.bat


in compile.bat

Code:
set STAGING_DIR=fullpath_to_project\ProjectName\Export\Android

call android update project --target 3 --path %STAGING_DIR%
call ant -buildfile Build.xml debug

pause


all compile fine on win XP and win 7

installing
Code:
adb install ProjectName-debug.apk

work fine

But when im run app on android emulator i see application name and black srcrean and application is off without any error code, just don't work :(

I try writing many haxe demo, try all emulator devices combination and do not work :(

Do you have some idea?

Btw. cool project ;)


Fri Feb 11, 2011 7:01 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.