Another newbie question - how to compile for Android?

Previous topic - Next topic

SFguy

I have another newbie question, and the answer is probably obvious to the experienced GLBasic coders here! :)

I'm now learning to program in GLBasic for Windows, but do not know how to make GLBasic compile to an APK file so that I can test to see if the program works on my Android mobile/cellphone.  Do I, for example, have to install the Android SDK?  Is there a link anywhere that I can go to to read up on the Android development process for GLBasic?

Thanks!

MrTAToad

You need the Java SDK (32 bit version) and to set JAVA_HOME and what not.

SFguy

Thanks for a quick reply!  Are you saying that I should go for the Java SE Development Kit for Windows x86 rather than for Windows x64?  If possible, can you also kindly explain why the latter will not work?  Thanks!

bigsofty

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

SFguy

Thanks for the helpful links, bigsofty!

erico

yep, there are a bunch of topics on that, check them first.
Let us know if trouble arrises that is not covered on the forum already.

But in general, you instal sdk6(32bit), yep, the x86 one.
You have to add a line on your system variable, the JAVA_HOME one. Those topics may cover that and the manual has some tips too.
Set your phone, of debbuging options or dev options to USB debugging.

Overall, in my case, it does not send the file automatically to the phone, so I have to copy the file glbasic-debug.apk, located on your projects folder, distribute/android/bin , after you compile,  to some location on your device, then you just run that and it should install and ask if you want to run it.

Be aware that you have to set your project resolution and in code resolution to that of your device if it is a quick test.
There is code around the forum that handles multiple resolution but so far I could not implement it.
My way, I hardcode the resolutions of the devices I want my app to run.

Cheers!

SFguy

Thanks to you guys for all the help!  I've installed the Java SDK, added the environmental variable, and rebooted (just in case).

erico, after compiling the program to android,  I see the distribute/android folder, but the only subfolders attached to this are: assets, libs, res, and src. I don't see a bin subfolder.  I assume the ASK file will be in the bin(ary) folder, but I don't see a bin folder.  Do you know where I'm going wrong?  :(

Sorry, I think I set the environment variable incorrectly - let me see to that first!

erico

That is strange, there should be a BIN folder in there, are you sure it is not hidden or something?
Inside you should find the glbasic-debug.apk

What are the msgs you get from the compiler window after you set it to compile to android?
Does it state that if found java and so on bla bla?

Don´t forget to add android to your project settings too just in case.

SFguy

Still can't find the BIN folder...  I got an output like this: not sure if this is good or bad! :)

_______________________________________
*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:e50f7495 - 3D, NET
Wordcount:165 commands
compile+link:
running Android build-script...
BUILD STAGE 1: Compile and pack RELEASE
Exception in thread "main" java.lang.RuntimeException: Failed to create Q:\Compiler\platform\android\android-sdk-windows\add-ons.
   at com.android.sdklib.SdkManager.loadAddOns(SdkManager.java:665)
   at com.android.sdklib.SdkManager.createManager(SdkManager.java:144)
   at com.android.sdkmanager.Main.parseSdk(Main.java:221)
   at com.android.sdkmanager.Main.run(Main.java:118)
   at com.android.sdkmanager.Main.main(Main.java:102)
Buildfile: build.xml does not exist!
Build failed
.
BUILD STAGE 2: Build DEBUG and install on device
Buildfile: build.xml does not exist!
Build failed
finished Android build-script.
Android=C:\Users\Robert\Documents\GLBasic files\Breakout\distribute\Android
success
_______________________________________
*** Finished ***
Elapsed: 3.7 sec. Time: 17:21
Build: 1 succeeded.

finnk

Try File -> Project -> Clean Up and then make another attempt.

SFguy

Thanks, finnk.

Unfortunately, same result after the clean-up. :(

SFguy

I also tried the advice from the following link:

http://www.glbasic.com/forum/index.php?topic=8013.msg67162#msg67162

by MrTAToad to "Try manually creating the add-ons directory in <program files>\Compiler\platform\android\android-sdk-windows\add-ons" in C:, C:/Program Files, and C:/Program Files (x86), but none of these seem to work either. :(

finnk

Maybe it has something to do with "GLBasic files" having a space in it. I don't know why I think that, but maybe that could have something to do with it. If you change it to an underscore, make sure to also modify anywhere that path might appear. Project settings etc... Also clean up again. Maybe even delete the auto-generated folders not a part of your project source and try building again.

SFguy

Good suggestions, finnk.  Let me change these and try again!

SFguy

OK, I finally got a bin folder and APK file by doing the following - I just added an "add-ons" folder to the following: "...\GLBasic\Compiler\platform\android\android-sdk-windows" folder.  This was from advice from the following thread: http://www.glbasic.com/forum/index.php?topic=8248.msg69715#msg69715

Sounds like a bug that should be corrected for the next version.

Update: Got it working on my Android - thanks to everyone who responded.  Of course, not perfectly as the screen size is wrong, but at least it is working! :)