GLBasic forum

Main forum => GLBasic - en => Topic started by: spudgunjake on 2011-Jul-07

Title: Help beginners guild to gettig GLBasic with Android.
Post by: spudgunjake on 2011-Jul-07
I have been using GLbasic with my Iphone for some time, I would like to use Glbasic with my new android desire S (Gingerbread).

Can anyone tell me, What I need to develop Android software with my GLbasic, I see lots of talk but no guild /  examples what I need to download to get working.

Can anyone help.

Best regards John.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2011-Jul-07
What you need to do is download the Android SDK and update it.  You also need to download the Java SDK too.

Once that is done, you need to setup various environment variables.  Once done you can then compile for Android.

I think this should cover most of the details you will need (taken from my GLBasic Programmers Reference Guide book) :

QuoteCompiling for Android is not as straight forward as the other platforms, as it requires the downloading (for development purposes only) of two other SDK's – the Java SDK and Android SDK

The Java SDK can be found at http://www.oracle.com/technetwork/java/javase/downloads/index.html, whilst the Android SDK is at http://developer.android.com/sdk/index.html

The Java SDK (only use the 32-bit version) can be installed anywhere (and can have spaces in the path name), and needs to be done before the Android SDK is installed.

Once done, you will need to add JAVA_HOME environment variable to point to the directory containing the version.  So, for example, if the version 6.25 of the JDK was installed in C:\Program Files (x86)\Java, JAVA_HOME would be set to C:\Program Files (x86)\Java\jdk1.6.0_25

This path should also be appended to the PATH variable too

Once done, the Android SDK can now be installed.  This should do in a directory path that has no spaces (so the usual Program Files directory is out!).  Usually on the first run, it will say that the Java SDK couldn't be found, but if you click on BACK and then NEXT again, it will be magically okay.

Before installing, make sure everything is selected.

Once completed, you have one more environment variable to setup.  This is called ANDROID_SWT and should be set to the 32-bit version of swt.jar in the android-sdk\lib directory.  So, for example, if the Android SDK was installed in C:\Android, ANDROID_SWT would be set to C:\Android\android-sdk\tools\lib\x86

As a GLBasic program can run on an Android emulator, you may want to test your programs on that first.  It should be noted that a lot of extensions are not supported, so the display may not be the same as an actual device.

To install an application on the emulator, you use (assuming %PATH% points to the Android program directory) :

adb install your_application.apk

With your your_application.apk pointing to the APK file that you want installed.

You can also grab emulator screenshots if you run ddms before you start the emulator.
Android Marketplace

Submitting an application to the Android Marketplace is just as simple as a webOS submission, although you do have to pay (at the time of writing) $25 (around 16.90 Euros or £14.98).

In addition, before you can submit a program, you have to sign it with a developer key.  To do so, follow these steps :

Build your application for Android
Make sure your JAVA paths are correct and setup in %PATH%
Create a folder called keytools and make a folder in that called keys.  The best place to do so would be the root of your GLBasic project folder
Copy the glbasic-debug.apk file in your projects android/bin directory, into the keytools directory.

As the APK file has been signed with a default key, this needs to be removed and replaced with one acceptable for the Marketplace.  This means using an application like WinRAR or 7ZIP to remove the contents of META-INF directory.  Once done, the code-signing process can continue :

Open a command prompt (CMD.EXE)
Move to the keytools folder (for example using C:\Users\Nicholas\Documents\GLBasic\Keytools)

Type in : keytool -genkey -alias mykey.keystore -keyalg RSA -validity 20000 -keystore keys/mykey.keystore

You will then be asked the following questions (all of which must be answered) :

Password
Full name
Name of your organisational unit
Name of your organisation
Name of City/Locality
State/Province
Two letter country code

After which, you can press RETURN to use the standard key.  Once you are back at the command prompt, type in the following : jarsigner -verbose -keystore keys/mykey.keystore -signedjar glbasic-signed.apk glbasic-debug.apk mykey.keystore

Your application will now be signed.  At this point, it would also be a good idea to zipalign the APK file.  This can be done by typing in :

zipalign -v 4 glbasic-debug.apk glbasic-signed.apk

which will output something like :

Verifying alignment of glbasic-signed.apk (4)...
      60 assets/Media/smalfont.png (OK)
    3944 res/drawable/icon.png (OK)
    8560 res/layout/main.xml (OK - compressed)
    8910 AndroidManifest.xml (OK - compressed)
    9652 resources.arsc (OK)
   10537 classes.dex (OK - compressed)
   20262 lib/armeabi/gdbserver (OK - compressed)
   94389 lib/armeabi/libmain.so (OK - compressed)
  596294 lib/armeabi/libmikmod.so (OK - compressed)
  699032 lib/armeabi/libSDL.so (OK - compressed)
  906556 lib/armeabi/libSDL_image.so (OK - compressed)
1008474 lib/armeabi/libSDL_mixer.so (OK - compressed)
1108476 lib/armeabi/libSDL_ttf.so (OK - compressed)
Verification succesful

When you have paid your Marketplace fees, you can submit your application to the store.  Acceptance is almost instant, so there is little in the way of application review before it is accepted.

In addition to the standard Android Market, it might also "pay" to submit it to the 1mobile.com site as well.  To do so, create an author account at http://author.1mobile.com/
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Kitty Hello on 2011-Jul-07
It should work with:
-Install Android SDK
-Install Java JDK (Java developer SDK)
-Set system environment variable JAVA_HOME like:
   JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_24
-Install GLBasic SDK v10 RC (or higher - for future reference)
-Set project options for "Android"
-Start the emulator or plug your real device in
-Build for Android
-Watch it run

(please add if  step is neded - I have to updat the manual, yet)
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: spudgunjake on 2011-Jul-07
Many thanks for the long info,

If I develop software for in-house apps would the signing be any different, with all use Android desire here, and we need some software for our solicitors  to use.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: spudgunjake on 2011-Jul-07
thanks Kitty, always very helpful.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2011-Jul-07
Code signing is quite easy.  Unfortunately I have found that no DOS based compression program (7zip, RAR, ZIP etc) will not handle Android APK files (as they say its in an invalid format), so everything has to be done by hand :(
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Kitty Hello on 2011-Jul-07
Did you try to rename it to "zip"?
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2011-Jul-07
Ah, yes, 7zip likes that...

WinRAR doesn't :)

Should be able to create a batch file to automate it all now :)
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Kitty Hello on 2011-Jul-07
 :nw:
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: spudgunjake on 2011-Jul-08
I have done I believe everything right, but When I compile now I get this. Im I missing something.

John.

*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.7.917 SN:72be2326 - 2D, NET
Wordcount:2180 commands
compile+link:
BUILDSRIPT

BUILD FAILED
T:\Compiler\platform\android\android-sdk-windows\tools\ant\main_rules.xml:639: The following error occurred while executing this line:
T:\Compiler\platform\android\android-sdk-windows\tools\ant\main_rules.xml:271: exec returned: 1

Total time: 22 seconds
Android=D:\GLBasic\iphone\distribute\Android
success
_______________________________________
*** Finished ***
Elapsed: 110.7 sec. Time: 10:59
Build: 1 succeeded.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2011-Jul-08
That sounds like the android icon file is missing - it wont get created with old projects. 

If you haven't got androidicon.png anywhere else, you'll need to create a new project, compile for Android and then copy it into your other project.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Goos on 2011-Jul-09
Hi i am programming GLBASIC for Android and it works great with my ASUS Transformer.
I want to know is ther a way to include a map in the APK. Glbasic makes a map for windows myprog.app and in there a map called media.
i must copy the map media to the android device. I have a program that uses the media map. So i want to ask if i can include it in the apk.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2011-Jul-09
Stick all data into the Media direction and it will be included when the APK file is created.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Goos on 2011-Jul-10
Thanks it worked like a charm.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: spudgunjake on 2011-Jul-10
I found the error I was getting was due to the emulator wasnt started or my HTC Desire wasnt plug in.

Every thing is working fine and I would like to thanks everyone for their input, 

best regrards John.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-30
This is probably a really stupid question, but Gernot stated above -

Quote-Set system environment variable JAVA_HOME like:
   JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_24

How and where exactly do I set the system environment?

I'm using Windows 7 64Bit. I've downloaded the Java and Android SDKs.

When compiling for Android I get this message-

Code (glbasic) Select

Android=C:\Users\Ian\Desktop\GLBasic\hello world\distribute\Android
*** Error: Environment variable JAVA_HOME must be set to JDK path
Please install the Java Development Kit and set the variable.
Example: C:\Program Files (x86)\Java\jdk1.6.xx

success
_______________________________________
*** Finished ***
Elapsed: 4.0 sec. Time: 16:47
Build: 1 succeeded.


I've searched the forums, but most help with regard to this is in German and "Set environment variable" means nothing to me.

:(
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: S.O.P.M. on 2013-Mar-30
http://www.itechtalk.com/thread3595.html

This should help, doesn't?
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-30
[EDIT] Actually no. It seemed to work once, but now I'm getting the same error message again.

I found this site - http://vietpad.sourceforge.net/javaonwindows.html but that didn't help either.

:giveup:

Can someone post a screenie of their Environment settings?

An idiots guide to setting up everything would be more than welcome :)
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: S.O.P.M. on 2013-Mar-30
You've installed the 32-Bit JDK? Yes, the compiler puts out 3 APK files,
glbasic-debug.apk
glbasic-debug-unaligned.apk and
glbasic-release-unsigned.apk
which are located in "..\distribute\Android\bin"
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-30
I've got that (see attachment), but GLB is spitting out -

Quote
*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:722cd5f9 - 3D, NET
Wordcount:3 commands
compile+link:
running Android build-script...
BUILD STAGE 1: Compile and pack

WARNING: Java not found in your path.
Checking if it's installed in C:\Program Files\Java instead (64-bit).

Java was found at C:\Program Files\Java\jre6\bin\java.exe.
Please consider adding it to your path:
- Under Windows XP, open Control Panel / System / Advanced / Environment Variables
- Under Windows Vista or Windows 7, open Control Panel / System / Advanced System Settings / Environment Variables
At the end of the "Path" entry in "User variables", add the following:
  ;C:\Program Files\Java\jre6\bin\java.exe

'"java.exe"' is not recognized as an internal or external command,
operable program or batch file.
BUILD STAGE 2: Install on device
'"java.exe"' is not recognized as an internal or external command,
operable program or batch file.
finished Android build-script.
Android=C:\Users\Ian\Desktop\GLBasic\hello_world\distribute\Android
success
_______________________________________
*** Finished ***
Elapsed: 5.4 sec. Time: 20:23
Build: 1 succeeded.

Did my Java not install properly? I got no error messages.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: S.O.P.M. on 2013-Mar-30
Your JAVA_HOME variable seems to be set as a user variable but has to be set as a system variable! Apart from that this beats me.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-30
It's set as both as you can see in the System Variable below. Is this not correct then?
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: S.O.P.M. on 2013-Mar-30
Now I noticed your system variable is named "PATH". Edit it and name it "JAVA_HOME" please. You don't need the user variable. The value of your variable must be your actual Java installation path -> "C:\Program Files (x86)\Java\jdkx.x.x"
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-30
That made no difference either. I've uninstalled all other versions of the Java SDK and now I get the message

Quote
*** Configuration: ANDROID ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:722cd5f9 - 3D, NET
Wordcount:3 commands
compile+link:
running Android build-script...
BUILD STAGE 1: Compile and pack

WARNING: Java not found in your path.
Checking if it's installed in C:\Program Files\Java instead (64-bit).
Checking if it's installed in C:\Program Files (x86)\Java instead.

Java was found at C:\Program Files (x86)\Java\jdk1.7.0_17\bin\java.exe.
Please consider adding it to your path:
- Under Windows XP, open Control Panel / System / Advanced / Environment Variables
- Under Windows Vista or Windows 7, open Control Panel / System / Advanced System Settings / Environment Variables
At the end of the "Path" entry in "User variables", add the following:
  ;C:\Program Files (x86)\Java\jdk1.7.0_17\bin\java.exe

'"java.exe"' is not recognized as an internal or external command,
operable program or batch file.
BUILD STAGE 2: Install on device
'"java.exe"' is not recognized as an internal or external command,
operable program or batch file.
finished Android build-script.
Android=C:\Users\Ian\Desktop\GLBasic\hello_world\distribute\Android
success
_______________________________________
*** Finished ***
Elapsed: 5.4 sec. Time: 21:16
Build: 1 succeeded.
So it knows I've got Java 1.7.0_17. I've even added the extra "\bin\java.exe" to the path and it makes no difference.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: okee on 2013-Mar-30
AFAIK you should only need the path to the Java root folder i.e it's
C:\Program Files (x86)\Java\jdk1.6.0_24    on my computer

If you click start and Run/Seach and type in %JAVA_HOME%
it will take you to the directory that  the variable JAVA_HOME is set to
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: dreamerman on 2013-Mar-30
I also have Win7 64bit, both 'jdk1.6.0_41' and 'jdk1.7.0_15' installed, but PATH variable was set to JDK 6, also JRE6 installed.

There can be problems with spaces in JAVA_HOME, so I keep all java/android stuff in 'c:/android/' ;d
Similar problem: http://www.glbasic.com/forum/index.php?topic=6868.msg56923#msg56923
Don't forget to set ANDROID_SWT as system variable, mine look like this: 'C:\Android\android-sdk\tools\lib\x86'
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: kanonet on 2013-Mar-30
I tried android compiling on 2 systems:
Win7 x64 -> installed Java SDK 7.0 32bit (did not install android sdk) -> did set JAVA_HOME -> everything worked fine (with bluestacks)
same setup on 2nd machine -> no success at all :( (doesnt matter for me, machine got replaced anyway).
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2013-Mar-31
I'm surprised I haven't covered this before.  But anyway :

Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: kanonet on 2013-Mar-31
You dont need the Android SDK, at least I dont have it and everything works fine.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: fuzzy70 on 2013-Mar-31
There is an Android ask installed with GLB in the "GLBasicCompilerplatformandroid" folder.


Lee


Sent from my HTC Wildfire using Tapatalk 2

Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: erico on 2013-Mar-31
I might be able to share a few ideas Ian...but I am away from hq. Be back in a couple days.
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-31
MrT - I have the 32bit version of Java (at least I think I have (x86)?) and the Android SDK.

QuoteIf you click start and Run/Seach and type in %JAVA_HOME%
it will take you to the directory that  the variable JAVA_HOME is set to

Windows puts up an error message stating
Quote"Windows cannot find  'C:\Program'. Make sure you typed the "name correctly, and then try again.

Perhaps Java isn't installing the SDK on my machine properly? It's documented in the Install/Uninstall Programs list.

Mr T - I notice from your screenie that the JAVA_HOME variable has a "\" after the "jdk1.7.0_15" bit - what else is after the "\"? I've tried "bin" and "bin\java.exe" nothing makes any difference.


BTW Thanks for all the help :)
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: Ian Price on 2013-Mar-31
Well, feq me!

It looks as this was all down to me using the wrong version of GLB! I was running the last version of v10 and got all those errors. As I've never technically upgraded to v11 I thought I'd try that and it all worked first time. I got the 3 .APK files (debug, debug-unaligned and release-unsigned).

So thanks for all your help, looks like a severe case of PEBCAK!

:happy:  :nw:  :good:  :booze:
Title: Re: Help beginners guild to gettig GLBasic with Android.
Post by: MrTAToad on 2013-Mar-31
True, but its always best to be safe :)