Game Development Community

Torque 2D for Android Ready

by Michael Perry · in Torque 2D Beginner · 10/28/2013 (11:47 am) · 122 replies

Android port is ready for testing. If you pull latest from the development branch, you can start using it. I don't have the time to write a formal blog yet, so spread the word. Feel free to start posting bug reports based on your own Android testing.
#41
11/01/2013 (8:29 am)
@Tim, thanks for the tip.

Here is what I want to achieve: I want my code to be able to tell (maybe using a certain callback) if the user has changed the device's orientation so I can swap the sceneWindow width and height (when Android system is changing its orientation, it really does not change our camera size and the scene just stretches or squeezes to match the new orientation, we need to manually swap width and height), something like this:

function sceneWindow::onOrientationChange( %Orientation )
{
    if (%Orientation $="landscape") sceneWindow.setCameraSize(100, 75);
    else sceneWindow.setCameraSize(75, 100);
}
#42
11/01/2013 (1:05 pm)
Ah. Yeah good idea. A callback is probably more useful. I'll add one when I get a chance.
#43
11/02/2013 (1:17 am)
finally a torque engine for android :)
thanks to gg and Tim Newell for his effort with the android port.
trying it now.
#44
11/02/2013 (1:34 am)
i am using latest ndk,adt.
version:
Android Developer Tools Build: v22.2.1-833290
android-ndk-r9

during build it shows these errors.
i think these are related to eclipse.
nothing to do with torque 2d part.
any idea?


A resource already exists on disk 'D:Torque2D Androidenginecompilersandroid.settings'
A resource already exists on disk 'D:Torque2D Androidenginecompilersandroid.settings'.
!MESSAGE Exception occurred while saving project preferences: /Torque2D/.settings/org.eclipse.jdt.core.prefs.
!ENTRY org.eclipse.core.resources 4 4 2013-11-02 13:32:13.176
!MESSAGE Exception occurred while saving project preferences: /Torque2D/.settings/org.eclipse.jdt.core.prefs.
!STACK 1
A resource already exists on disk 'D:Torque2D Androidenginecompilersandroid.settings'.

!ENTRY org.eclipse.egit.ui 2 0 2013-11-02 13:32:14.142
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:UsersAdministrator'.
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git.

#45
11/02/2013 (1:48 am)
here is full log:
http://pastebin.com/QhSTvztA
#46
11/02/2013 (6:47 am)
That does look to be some weird issue with eclipse not being able to save a file. Does your D drive have any kind of restricted access? Like do you need to be admin to use it? You could try running eclipse as admin to see if it fixes it. If you have not already, make sure you follow the documentation setup guide for getting eclipse setup with the NDK and torque2d.
#47
11/02/2013 (6:56 am)
solved.
not for those warning. there were some other unknown issue with:
"Eclipse SDK Version: 4.2.0Build id: I20120608-1400"
that is why Eclipse was unable to run the application.

using eclipse from ADT package solved it.

********************************
after release build,
is there any way to test the game in android emulator
instead of transferring each new build to mobile/device?

+
how much time it takes to do the release build and debug build?
my 1st release build took 1 hour.
and debug build still going on( almost 35% in 25 minute).
is that normal?
any way to speed up the build process?
i have 8 gb ram with 4 core i5 processor.
#48
11/02/2013 (9:14 am)
Quote:
Stop the debug session after torque launches and look for a file called gdb.setup located in obj/local/armeabi-v7a/


instead of "enginecompilersandroidobjlocalarmeabi-v7a"
i found it under "enginecompilersandroidlibsarmeabi-v7a".

and no "target remote :5039" in it.
#49
11/02/2013 (9:20 am)
Yeah I always use the eclipse packaged with ADT because trying to manually add ADT to eclipse always had issues when I tried.

You can try creating an emulator in eclipse but I have never had any luck with them. They are VERY slow and last time I tried with a project that uses the NDK it would not work at all.

On my macbook (which is similar specs except I have 4gb of ram) it definitely does not take that long. Maybe 10 minutes at most for a full rebuild. I did have to add two settings to the NDK build files for windows because it was erroring out on long commands. I have not tried on windows but I have been told they make the build process longer.

Edit: That gdb.setup might be invalid. if it did not generate one, try opening command line in the engine/compiler/android folder and run ndk-gdb while the game is running and see if that generates it.
#50
11/03/2013 (8:35 pm)
Great work, Tim.

when I test the Oct 31 source in my 2.3.6 android device, if I close screen during running demo, and I reOpen screen, T2D demo shows a black screen only, and I can't input also. and I test this on 4.1 android device, t2d works well. could t2d solve the problem in 2.3.6 to 2.2 ?

BTW, how could I test android keyboard input?

Many Thanks.
#51
11/03/2013 (11:11 pm)
and how to show utf8 foreign language? chinese for example.
any clue will be thankful.
#52
11/04/2013 (4:39 am)
I don't have an old enough device to debug that issue. Can you debug it or anyone else on here who has an older device? There are instructions in the doc on setting up debugging in eclipse.

Keyboard input is not totally done yet. It was not really part of the contract since keyboard support does not work on iOS either. I was just using some spare time to contribute to it and try to get it working.

As far as foreign language support goes, Does it work on windows in t2d right now? I was basing the keymap code on windows the best I could. I have not done any foreign language support before so if someone on here has, maybe they can help contribute?
#53
11/04/2013 (5:09 am)
in android I use class "FileObject" to write info to a file "/data/data/com.garagegames.torque2d/cache/test.dat". but read out is different, file size is right.

write method is "FileObject::writeLine", and read method is "FileObject::readLine", how could this happen?

any clue will be thankful.
#54
11/04/2013 (5:30 am)
I would love to debug that issue, I'm a newbie to android and osx, so I will work on setting up debbugging in eclipse, now I'm working on windows and using log info to debug.

shows black in 2.3.6 device, I guess it's in some kind of death loop, so where to start debug that issue? if there is some clue will be better. if I fix the issue, I will post all source code.

Many thanks.
#55
11/04/2013 (10:13 am)
when you say the read out is different on FileObject, do you mean it cant read the file at all or that it reads the file incorrectly?

On the debugging front, you dont need osx, those instructions I gave should work on windows as well. A good place to start would be to see if the opengl context is being recreated correctly on that device. in eclipse expand jni/source/platformAndroid/ and open file T2DActivity.cpp. Put a breakpoint in engine_init_display(). This function is called on start but also on resume. So it may trigger the breakpoint when you start the application, if so just keep continuing until the game starts. then try suspend/resuming the app and when break point hits step through it and make sure things are being created correctly.
#56
11/04/2013 (12:58 pm)
just look it
Great work guys!
Big event in T2D community!
#57
11/04/2013 (1:23 pm)
Awesomeness! What a good thing to learn about! Thanks Tim.
#58
11/04/2013 (6:51 pm)
@Tim it reads the file incorrectly, and file size reads right.
#59
11/04/2013 (7:51 pm)
I can't find "2.Open AndroidManifest.xml and click the Application tab. Scroll down to the Debuggable flag and set it to true." mentioned in "Android Development Guide"

Thanks.
#60
11/05/2013 (2:51 am)
can you give me an example of what the it reads in versus what it should read in? You don't have to give me the whole file just part of it.

AndroidManifest.xml is in the file list on the left in eclipse. Its not in the jni folder, its in the main folder.