{"id":844,"date":"2012-09-28T08:39:13","date_gmt":"2012-09-28T12:39:13","guid":{"rendered":"http:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/?p=844"},"modified":"2012-09-28T09:00:58","modified_gmt":"2012-09-28T13:00:58","slug":"haxenme-android-on-arch","status":"publish","type":"post","link":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2012\/09\/haxenme-android-on-arch\/","title":{"rendered":"Haxe\/NME Android on Arch"},"content":{"rendered":"<p>These are some notes, the tricky parts mostly from tom5760, on building Haxe\/NME apps for Android.<\/p>\n<p>First install Ant and Java using the standard tools. Despite various warnings around, I have not had a problem using Java7 (OpenJDK). \u00a0Then install the Android tools using the AUR packages <code>android-sdk android-sdk-platform-tools android-ndk<\/code>. I use packer, so it&#8217;s as simple as:<\/p>\n<pre>\r\n$ sudo packer -S android-sdk \\\r\n                 android-sdk-platform-tools android-ndk\r\n<\/pre>\n<p>After that you need to use the android manager to install support for your API and device targets, like usual.<\/p>\n<p>Next configure NME with the right paths by running <code>nme setup android<\/code>. Note that you need to do this as your user, not sudo. Opt not to download any of the packages. If you did a standard install you should have <code>JAVA_HOME<\/code> and <code>ANT_HOME<\/code> set for it to detect, but these are the standard paths:<\/p>\n<ul>\n<li>SDK: <code>\/opt\/android-sdk<\/code><\/li>\n<li>NDK: <code>\/opt\/android-ndk<\/code><\/li>\n<li>Ant: <code>\/usr\/share\/apache-ant<\/code><\/li>\n<li>Java: <code>\/usr\/lib\/jvm\/java-7-openjdk<\/code><\/li>\n<\/ul>\n<p>After that, projects still won&#8217;t compile. You&#8217;ll probably get errors like this:<\/p>\n<pre>\r\nCreating hxcpp.h.gch...\r\n[ huge compile command... ]\r\n\/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hxcpp.h:13:20: error: typeinfo: No such file or directory\r\nIn file included from \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hxcpp.h:170: \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/Array.h:195:21: error: algorithm: No such file or directory\r\nIn file included from \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hxcpp.h:162: \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hx\/Object.h: In member function 'void hx::ObjectPtr::CastPtr(hx::Object*)': \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hx\/Object.h:143: error: must #include before using typeid\r\nIn file included from \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hxcpp.h:170: \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/Array.h: In member function 'void Array_obj::sort(Dynamic)': \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/Array.h:388: error: 'sort' is not a member of 'std'\r\nIn file included from \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/hxcpp.h:171: \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/Class.h: In function 'bool hx::TCanCast(hx::Object*)': \/usr\/lib\/haxe\/lib\/hxcpp\/2,10,2\/\/include\/Class.h:139: error: must #include before using typeid\r\nCalled from ? line 1\r\nCalled from BuildTool.hx line 1301\r\nCalled from BuildTool.hx line 567\r\nCalled from BuildTool.hx line 604\r\nCalled from BuildTool.hx line 738\r\nCalled from BuildTool.hx line 767\r\nCalled from BuildTool.hx line 162\r\nUncaught exception - Error creating pch: 256 - build cancelled\r\nError: Source path \"bin\/android\/obj\/libApplicationMain.so\" does not exist\r\n<\/pre>\n<p>These are caused by Haxe\/NME not locating the NDK libraries correctly. Recent versions of Android reorganized the directory structure a bit, so you have to do this:<\/p>\n<pre>\r\ncd $ANDROID_NDK\/sources\/cxx-stl\/gnu-libstdc++\r\nln -s 4.4.3\/libs\r\nln -s 4.4.3\/include\r\n<\/pre>\n<p>Apparently version 4.6 (the latest as of this writing) doesn&#8217;t work.<\/p>\n<p>At that point, everything should work, but I got an error like this:<\/p>\n<pre>\r\nCopy bin\/android\/obj\/libApplicationMain.so to bin\/android\/bin\/libs\/armeabi\/libApplicationMain.so\r\ncd bin\/android\/bin\r\n\/SDKs\/\/ant\/bin\/ant debug\r\nsh: \/SDKs\/\/ant\/bin\/ant: No such file or directory\r\nCalled from ? line 1\r\nCalled from InstallTool.hx line 679\r\nCalled from InstallTool.hx line 119\r\nCalled from installers\/InstallerBase.hx line 229\r\nCalled from installers\/AndroidInstaller.hx line 56\r\nCalled from helpers\/AndroidHelper.hx line 53\r\nCalled from helpers\/ProcessHelper.hx line 125\r\nCalled from InstallTool.hx line 152\r\nCalled from \/usr\/lib\/haxe\/std\/neko\/Lib.hx line 63\r\nCalled from helpers\/ProcessHelper.hx line 119\r\nCalled from helpers\/ProcessHelper.hx line 169\r\nUncaught exception - Error running: \/SDKs\/\/ant\/bin\/ant debug [bin\/android\/bin]\r\n<\/pre>\n<p>To fix that, I edited <code>~\/.hxcpp_config.xml<\/code> to set the various paths:<\/p>\n<pre>\r\n&lt;section id=\"vars\"&gt;\r\n&lt;set name=\"SDK_ROOT\" value=\"\/SDKs\/\" \/&gt;\r\n&lt;set name=\"ANDROID_SDK\" value=\"\/opt\/android-sdk\" \/&gt;\r\n&lt;set name=\"ANDROID_SETUP\" value=\"true\" \/&gt;\r\n&lt;set name=\"ANDROID_NDK_ROOT\" value=\"\/opt\/android-ndk\/\" \/&gt;\r\n&lt;set name=\"ANT_HOME\" value=\"\/usr\/share\/apache-ant\" \/&gt;\r\n&lt;set name=\"JAVA_HOME\" value=\"\/usr\/lib\/jvm\/java-7-openjdk\" \/&gt;\r\n&lt;\/section&gt;\r\n<\/pre>\n<p>I have not done more yet to figure out why I needed to do that.<\/p>\n<p>Note also that you need to include the following NDLLs in your .nmml to compile for Android, though they don&#8217;t seem to be needed for other platforms:<\/p>\n<pre>\r\n&lt;ndll name=\"std\" \/&gt;\r\n&lt;ndll name=\"regexp\" \/&gt;\r\n&lt;ndll name=\"zlib\" \/&gt;\r\n&lt;ndll name=\"nme\" haxelib=\"nme\" \/&gt;\r\n<\/pre>\n<p>The latter seems to be needed even if including the nme haxelib. Again, I have not investigated farther.<\/p>\n<p>The Android target also does not like the <code>portrait=\"*\"<\/code> option in the nmml file, you must specify landscape or portrait.<\/p>\n<p>At this point, you should be able to build and run Android apps, e.g.:<\/p>\n<pre>\r\n\/usr\/lib\/haxe\/lib\/nme\/3,4,4\/samples\/02-Text\/\r\nnme test Sample.nmml android\r\n<\/pre>\n<p>Note that the above will only work if you can write to the samples dir, e.g., <code>chown -R joe \/usr\/lib\/haxe\/lib\/nme\/3,4,4\/samples\/<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>These are some notes, the tricky parts mostly from tom5760, on building Haxe\/NME apps for Android. First install Ant and Java using the standard tools. Despite various warnings around, I have not had a problem using Java7 (OpenJDK). \u00a0Then install the Android tools using the AUR packages android-sdk android-sdk-platform-tools android-ndk. I use packer, so it&#8217;s &hellip; <a href=\"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2012\/09\/haxenme-android-on-arch\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[110,99,82,100,78],"class_list":["post-844","post","type-post","status-publish","format-standard","hentry","category-code","tag-android","tag-arch","tag-haxe","tag-linux","tag-nme"],"_links":{"self":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/comments?post=844"}],"version-history":[{"count":6,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"predecessor-version":[{"id":850,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/844\/revisions\/850"}],"wp:attachment":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}