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.
#61
11/05/2013 (4:35 am)
thanks for the reply, first I write something:
char szBuf[256] = {0};
dSprintf(szBuf, 255, "%s/Info.dat", Platform::getUserDataDirectory());
FileObject stFile;
bool bResult = stFile.openForWrite(szBuf, false);

stFile.writeLine((const U8 *)szPlayerName);
stFile.writeLine((const U8 *)szPlayerInfo);

stFile.close();

then I close the app, and reOpen the app, It reads:
char szBuf[256] = {0};
dSprintf(szBuf, 255, "%s/Ino.dat", Platform::getUserDataDirectory());
FileObject stFile;
if ( stFile.readMemory(szBuf))
{
char szPlayerName[20] = {0}, szPlayerInfo[32] = {0};
dStrncpy(szPlayerName, (const char *)stFile.readLine(), sizeof(szPlayerName) -1);
dStrncpy(szPlayerInfo, (const char *)stFile.readLine(), sizeof(szPlayerInfo) -1);
stFile.close();
}

results are different. Info read out is Garbled.

Thanks.
#62
11/05/2013 (6:08 am)
to debug when i click eclipse's bug button,
in my phone it only shows splash screen for 1 sec and then quits.

then eclipse shows a message box having:

An internal error occurred during: "Launching Torque2dDebugNative".


very last part of log:

Quote:
--------------------------------------------------------------------------------
I/Torque2D(9448): [2013/11/05 19:51:34] Video initialization:
207: I/Torque2D(9448): [2013/11/05 19:51:34] Accelerated OpenGL display device detected.
:34.208: I/Torque2D(9448): [2013/11/05 19:51:34]
:34.208: D/dalvikvm(9448): threadid=11: interp stack at 0x5e5f2000
:34.211: D/dalvikvm(9448): GC_FOR_ALLOC freed 0K, 10% free 20291K/22343K, paused 12ms, total 12ms
:34.213: W/dalvikvm(9448): dvmFindClassByName rejecting 'com/garagegames/torque2d/FileWalker'
:34.226: D/dalvikvm(9448): GC_CONCURRENT freed 8K, 10% free 20288K/22343K, paused 2ms+3ms, total 15ms
:34.612: D/skia(9448): Flag is not 10
:34.622: D/dalvikvm(9448): GC_FOR_ALLOC freed 3K, 10% free 20286K/22343K, paused 9ms, total 9ms
:34.625: I/dalvikvm-heap(9448): Grow heap (frag case) to 21.853MB for 2073616-byte allocation
:34.635: D/dalvikvm(9448): GC_FOR_ALLOC freed <1K, 9% free 22311K/24391K, paused 10ms, total 10ms
:34.649: D/dalvikvm(9448): GC_CONCURRENT freed <1K, 9% free 22312K/24391K, paused 1ms+2ms, total 13ms
:34.722: D/OpenGLRenderer(9448): Enabling debug mode 0
:34.723: V/InputMethodManager(9448): onWindowFocus: null softInputMode=288 first=true flags=#1830500
:34.723: V/InputMethodManager(9448): Not IME target window, ignoring
:34.777: V/threaded_app(9448): WindowFocusChanged: 0x5c1fe348 -- 0
:34.857: I/torque2d(9448): time in java: 643.0
:34.858: D/dalvikvm(9448): threadid=11: bye!
:34.859: I/Torque2D(9448): [2013/11/05 19:51:34] []Input::disable.
:34.861: A/libc(9448): Fatal signal 11 (SIGSEGV) at 0x00004000 (code=1), thread 9464 (egames.torque2d)

here is full log:
http://pastebin.com/ijdBB9iz
i also have tried by installing
engine\compilers\android\bin\Torque2D.apk

same result.
my phone configuration:
cpu MT6589 (quad core armv7)
frequency:
497-1209 mhz
gpu:
powervr sgx 544mp
memory:
970 mb


+
there is no "gdb.setup" inside my " obj/local/armeabi-v7a/".
i have one under "engine\compilers\android\libs\armeabi-v7a\gdb2.setup"
and it have no line
"target remote :5039".
i have pointed that one as GDB Command File

is that ok?

here is content of my gdb2.setup:
set solib-search-path ./obj/local/armeabi-v7a  
directory H:/Android/android-ndk-r9/platforms/android-9/arch-arm/usr/include H:/Android/android-ndk-r9/sources/android/native_app_glue jni H:/Android/android-ndk-r9/sources/cxx-stl/stlport jni/../../../lib/ljpeg jni/../../../lib/lpng jni/../../../source jni/../../../source/2d jni/../../../source/2d/assets jni/../../../source/2d/controllers jni/../../../source/2d/core jni/../../../source/2d/experimental/composites jni/../../../source/2d/gui jni/../../../source/2d/sceneobject jni/../../../source/algorithm jni/../../../source/assets jni/../../../source/audio jni/../../../source/box2d jni/../../../source/box2d/Collision jni/../../../source/box2d/Collision/Shapes jni/../../../source/box2d/Common jni/../../../source/box2d/Dynamics jni/../../../source/box2d/Dynamics/Contacts jni/../../../source/box2d/Dynamics/Joints jni/../../../source/box2d/Rope jni/../../../source/collection jni/../../../source/component jni/../../../source/component/behaviors jni/../../../source/console jni/../../../source/debug jni/../../../source/debug/remote jni/../../../source/delegates jni/../../../source/game jni/../../../source/graphics jni/../../../source/gui jni/../../../source/gui/buttons jni/../../../source/gui/containers jni/../../../source/gui/editor jni/../../../source/gui/language jni/../../../source/input jni/../../../source/io jni/../../../source/io/resource jni/../../../source/io/zip jni/../../../source/math jni/../../../source/memory jni/../../../source/messaging jni/../../../source/module jni/../../../source/network jni/../../../source/persistence jni/../../../source/persistence/taml jni/../../../source/persistence/taml/binary jni/../../../source/persistence/taml/json jni/../../../source/persistence/taml/xml jni/../../../source/persistence/rapidjson/include jni/../../../source/platform jni/../../../source/platform/nativeDialogs jni/../../../source/platformAndroid jni/../../../source/sim jni/../../../source/string jni/../../../lib/freetype/android/include jni/../../../lib/freetype/android/include/freetype2 H:/Android/android-ndk-r9/sources/cxx-stl/stlport/stlport H:/Android/android-ndk-r9/sources/cxx-stl//gabi++/include jni/../../../lib/openal/Android/openal-soft-master/jni/OpenAL/include
#63
11/05/2013 (6:16 am)
@DieRich I will debug your example when I get a chance to see what is going on.

@ahsan That gdb2.setup is one from my machine so it may not work specially if you are on windows. I assume the game works fine in release? Are you familiar with gdb command line tool?

I am not familiar with android development on windows, but on mac I startup the game normal, then open terminal and cd to engine/compilers/android and run ndk-gdb After running that type in continue as it'll pause execution of the game. Can you see if that works for you? Although if you cannot even install the debug apk and it work it sounds like some difference in release and debug build causing you issues. Try opening jni/Android.mk and go down to the bottom where it checks if it is a debug build or release build and try removing -DTORQUE_DEBUG and see if it helps.
#64
11/05/2013 (7:51 am)
i am having hard time with eclipse.
worst part is building.each rebuild take around 1 hour.
and now debug and breakpoint is not working.

thanks for answer.i will give a go with your suggetions.
here,
anybody using windows 7 64 bit with latest adt for t2d android building?
any similer cases?
#65
11/05/2013 (9:01 pm)
" try removing -DTORQUE_DEBUG and see if it helps."
tried and failed.
nothing is happening on debug mode.

"cd to engine/compilers/android and run ndk-gdb"
tried.but "run ndk-gdb" shows error.
i also tried with "run H:\Android\android-ndk-r9\ndk-gdb"

" I assume the game works fine in release?"
i have tested with "Torque2D.apk"( auto created during run command).
that only shows splash screen for 1/2 sec .
no game screen .


" Are you familiar with gdb command line tool?"
what u want me to do in cmd?

***************
the only thing i have left to try is latest jdk and an updated driver for my phone.



is this error have something to do with:
[2013-11-06 08:49:05 - Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath": CreateProcess error=2, The system cannot find the file specified
#66
11/05/2013 (11:47 pm)
@Tim Thanks very much.

@ahsan I'm using newest jdk and adt, and Eclipse is in the adt.

I can't debug c++, if there is a video to teach us how to set up all the stuff will be more thankful.

and I find out it's impossible to write file in android in c++(except "Cache" folder), Am I right? and how to write file on android?

Thanks.
#67
11/06/2013 (1:29 am)
"I can't debug c++, "
what happen to release build?
does your game start or just shows a splash screen for 1/2 sec ?


"if there is a video to teach us how to set up all the stuff will be more thankful."

first someone have to make it work on windows 7 only then video can be made.anyone have success debugging on windows?
or any successful release build using windows?
#68
11/06/2013 (3:40 am)
@ahsan What device do you have? What version of Android is running on it?
#69
11/06/2013 (4:57 am)
" What device do you have? "

it is a local brand mobile using mediatek processor. configuration:


model:Walton primo n1
cpu:
MT6589(quad core armv7)
http://www.mediatek.com/_en/01_products/04_pro.php?sn=1081)

cpu frequency: 497-1209 mhz
gpu:powervr sgx 544mp
memory:970 mb





What version of Android is running on it?


os: android 4.1.2
kernel: linux version 3.4.5 (22th april 2013)


******************************
tomorrow i will try to do a test with "samsung galaxy s".
if that works well then most probably my phone driver have problem.

***************
@tim, can u upload a release build "Torque2D.apk" and a debug version also?
i will try to run them on my device.
#70
11/06/2013 (6:53 am)
Yeah I'll upload them when I get a chance today. It is possible its something with your dev environment because others on windows I have talked to said it only took them around 4 minutes for a full compile on a slower machine than you have.
#71
11/06/2013 (7:19 am)
thanks.i will wait for those.

"It is possible its something with your dev environment "
i also think so.

"I have talked to said it only took them around 4 minutes for a full compile on a slower machine than you have."

any chance to have a video workflow of their process?
do they have "gdb.setup" inside " obj/local/armeabi-v7a/" ?
#72
11/06/2013 (7:32 am)
I believe they were compiling in release mode, but didn't you say release mode takes that long too? Or did I misunderstand and it is only debug mode? Btw, you can compile a debug build without doing the gdb-setup, you just cannot debug from eclipse without it (but you can still debug from command line)
#74
11/06/2013 (9:47 pm)
sorry for late answer.

"didn't you say release mode takes that long too?"

yes.debug takes around 1hour.
sometimes more then 1 hour.
and release build takes 30-40 minute.


all of my "Torque2D.apk" are 2/3 mb only.
so it is obvious by build environment have problems.
i will do a test from someone else's pc.

thanks for the uploads.
i should have asked them before.
#75
11/07/2013 (8:15 am)
Are those apks a custom project or the sandbox? It sounds like you did not follow all of the steps at the bottom of the docs. One of them is you have to manually copy the modules and main.cs into the engine/compilers/android/assets folder.
#76
11/07/2013 (10:14 am)
"Are those apks a custom project or the sandbox? It sounds like you did not follow all of the steps at the bottom of the docs."

ya.
i skipped that part for it's title " for Deploying to a Device".
for that title i thought it is only needed for deployment.
not essential for testing through usb or using avd for emulator.


and also forgot when was copying "engine\compilers\android\bin\Torque2D.apk" to device.

going to try it now.
again have to wait 40 minute to do the release build.
#77
11/07/2013 (1:32 pm)
release build is working now.
sorry for bothering without following deployment instruction.
that title mislead me.

***********
debug build is running now.
but breakpoint is not working.
#78
11/07/2013 (2:49 pm)
Debugging in eclipse is tricky and doesn't work half the time. I think a main thing you are missing is setting up the gdb2.setup properly. You said you were using the one I had uploaded but I am not sure that will work on anyone else's machine. This is an older article, but it is what I followed for setting up eclipse ndk debugging. It will explain how to generate the gdb.setup in the correct directory so you can copy it and remove that line so eclipse can connect to it. See if this helps you get it setup properly. The eclipse UI in this article is going to be different, but you can refer to my documentation for that part of it. Getting eclipse to start NDK debugging is very frustrating :)

mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/
#79
11/07/2013 (10:33 pm)
"You said you were using the one I had uploaded but I am not sure that will work on anyone else's "

nope.during each debug build a new "gdb.setup" created.
i was using that.


and there is no "gdb.setup" file in devlopment branch.
#80
11/09/2013 (6:00 am)
hi Tim, how is everything going with my file reading issue mentioned in #61?