How to create an Android application

Share your advanced knowledge/code with the community.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

How to create an Android application

Post by falsam »

Create an Android application.

Installing the JDK 1.8
Link http://www.oracle.com/technetwork/java/ ... 33151.html

Configuring the IDE: Specify the JDK installation folder.
IDE : Menu file ➽ Preference ➽ Compiler

Image

Configure the application.
Prepare your first code and save it.

Code: Select all

Enumeration
  #mf
  #mfFont
  #mfTime
EndEnumeration

Declare Start()
Declare ShowTime()

;No debug
CloseDebugOutput()

Start()

Procedure Start()
  
  LoadFont(#mfFont, "", 50)
  
  OpenWindow(#mf, 0, 0, 0, 0, "", #PB_Window_Background)
  TextGadget(#mfTime, 10, 100, 300, 50, "00:00:00")
  SetGadgetFont(#mfTime, FontID(#mfFont))
  
  AddWindowTimer(#mf, 0, 1000)
  BindEvent(#PB_Event_Timer, @ShowTime())
EndProcedure

Procedure ShowTime()
  Protected Time.s = FormatDate("%hh:%ii:%ss", Date())
  SetGadgetText(#mfTime, Time)
EndProcedure
It's time to set up your Android application.

Configuring the APK: An android application has the.apk extension
IDE : Menu Compiler ➽ Create App

Image

App Name : Name that will appear when installing the apk.

Version : Version of your application. To be incremented with each generation of the APK. Example : 1.0.0

Package id (lower case): Identifier of the Android application.
Package name : extensiondedomaine.nomdudomaine.android.nomduprojet

:idea: .android is optional.

You don't have to have a domain to publish an application. You can take for example your nickname on this forum.
Example : com.falsam.firstapplication

Outfile Filename : Application name for Android.

Ok button to save the configuration.
Create App button to create the Android application.

Image

With this example, I transferred the final apk to a tablet and smartphone manually via the usb cable.

Transfers of unknown applications.
Installing unknown applications (Internet, alternative store, USB transfer, etc...) requires changing phone settings to allow applications from unknown sources.

Mobile : Parameters ➽ General tab ➽ Security: Check Unknown sources.
Last edited by falsam on Mon Mar 26, 2018 5:42 pm, edited 1 time in total.

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: How to create an Android application

Post by falsam »

If you have successfully created your first application for Android (YeahhHHhhhh), I suggest you test this code to turn on or off your terminal's lamp.

http://forums.spiderbasic.com/viewtopic.php?f=9&t=1456

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
munfraid
Posts: 104
Joined: Sat Mar 24, 2018 1:33 pm

Re: How to create an Android application

Post by munfraid »

Thanks, falsam, for this sample and instruction - very helpful! I love all the things you share here and yet learned a lot from them.

Merci, falsam, pour cet exemple et cette instruction - très utile ! J'aime toutes les choses que vous partagez ici et pourtant j'ai beaucoup appris d'eux.
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Re: How to create an Android application

Post by tj1010 »

This tutorial already exists here, but IAP is the in app purchases key you get from your store panel, and package ID is a unique identifier on store and is used for nothing else; there is a bug with it and webview in older Android versions, but it's probably worked around by the SB team. There is a signing tool in the how-to-sign thread.
Peter53
Posts: 12
Joined: Thu Mar 28, 2019 2:58 pm

Re: How to create an Android application

Post by Peter53 »

Hi.
Sadly I can't get it to compile to Android.
At 60%, I get the 'app build failed' message.
I'm using SB 2.21, Windows 10.
Downloaded and installed Java jdk-8u202-windows-i586.exe from here:
https://www.oracle.com/technetwork/java ... 33151.html (Tried defferent versions).
I've set the JDK path to "C:\Program Files (x86)\Java\jdk1.8.0_202\"
Any help is truly appreciated.
Thanks
Dan23
Posts: 1
Joined: Fri May 24, 2019 1:43 pm

Re: How to create an Android application

Post by Dan23 »

Hello,
I have the same problem: Invalid Version: broken! under the same conditions.
Whatever the program.
Where does this error come from?.
Spider Basic? of a bookstore?, yes but which one?
At 40%, I receive the message "app build build failed".
After each trial, I am forced to restart SpiderBasic.
I use SB 2.21 (x86, impossible to get 64 bits).Paid version
Windows 7 Pro Pack 1.
JDK path to "C: \ Program Files \ Java \ jdk1.8.0_211 \"
"Enable debugger" is enabled.
Everything seems correct. It's very frustrating.
Thank you
MetalOS
Posts: 6
Joined: Thu Oct 27, 2016 7:58 am

Re: How to create an Android application

Post by MetalOS »

Hi Falsam,

you will have an example of android application but with several windows. A simple trick to see how to manage multiple windows I'm looking for nothing more.

Thank you in advance.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: How to create an Android application

Post by falsam »

Hi MetalOS

No real window in an apk (except for a tablet application).

Navigation between windows will be done through containers.

This little code doesn't record any data. It is a simple demonstration of navigation between two windows.

Code: Select all

Enumeration font
  #GlobalFont
  #TitleFont
EndEnumeration

Enumeration window
  #mf  
EndEnumeration

Enumeration gadget
  #mf0
  #mf1
  
  #mfTitle
  #mfTodoList
  #mfTodo
  #mfNewItem
  #mfAddItem
EndEnumeration

Global width, height

Declare Start()
Declare TodoList()
Declare TodoNew()
Declare TodoAdd()

Start()

Procedure Start()
  ; Really close the debug window 
  CloseDebugOutput()
  !$('div').eq(0).remove()
  
  ; Font
  LoadFont(#GlobalFont, "Arial", 16)
  LoadFont(#TitleFont, "Arial", 20)    
  SetGadgetFont(#PB_Default, FontID(#GlobalFont))
  
  ; Background window
  OpenWindow(#mf, 0, 0, 0, 0, "", #PB_Window_Background)  
  
  width = WindowWidth(#mf)
  height= WindowHeight(#mf) 
  
  ; Title
  TextGadget(#mfTitle, 5, 5, 200, 24, "Todo List")
  SetGadgetFont(#mfTitle, FontID(#TitleFont))
  
  ; First page
  If ContainerGadget(#mf0, 0, 30, width, height)
    ListViewGadget(#mfTodoList, 5, 0, width - 10, height - 100)
    ButtonGadget(#mfNewItem, 5, height - 70, width - 10, 24, "New item")
    CloseGadgetList()
  EndIf
  
  ; Second page
  If ContainerGadget(#mf1, 0, 30, width, height)
    StringGadget(#mfTodo, 5, 0, width - 10, 24, "")
    ButtonGadget(#mfAddItem, 5, height - 70, width - 10, 24, "Add item")    
    CloseGadgetList()
  EndIf  
  
  ;Trigger
  BindGadgetEvent(#mfNewItem, @TodoNew())
  BindGadgetEvent(#mfAddItem, @TodoAdd())
  
  TodoNew()
EndProcedure

Procedure TodoList()  
  HideGadget(#mf0, #False)
  HideGadget(#mf1, #True)
EndProcedure

Procedure TodoNew()
  HideGadget(#mf0, #True)
  HideGadget(#mf1, #False)
  
  SetGadgetText(#mfTodo, "Item " + Str(CountGadgetItems(#mfTodoList)))  
EndProcedure

Procedure TodoAdd()
  Protected buffer.s = GetGadgetText(#mfTodo)
  
  AddGadgetItem(#mfTodoList, -1, Buffer)
  TodoList()
EndProcedure
The listview is scrolled with the finger ^^

Enjoy

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
MetalOS
Posts: 6
Joined: Thu Oct 27, 2016 7:58 am

Re: How to create an Android application

Post by MetalOS »

Nickel, Merci Falsam.
Peter53
Posts: 12
Joined: Thu Mar 28, 2019 2:58 pm

Re: How to create an Android application

Post by Peter53 »

This only concerns people using Windows 10 and Windows 10 Privacy Tool
available from this site: https://www.winprivacy.de/english-home/
Since SpiderBasic version 2.0, I have been unable to compile for
Android. An annoying crash happened each and every time at 60%.
No information, no hints and no way to explain why the compiler
stopped....Unable to give Fred any hints of ANY kind, I settled
for version 2.0 and did what I had to do..
Recently I bought new ssd drives, gfx card and other hardware which
required a completely new installation. Latest SpiderBasic and jdk installed
but this time I omitted the privacy tool...and there it was..!
Working like a charm. For the first time I was able to compile for Android
on a version greater then 2.0! Lovely!!
Now...Using a privacy tool can be a nice thing, but it does pose several
problems in doing so. At default settings, the privacy tool will
automatically tinker with telemetry and so forth....and this is some of the
issues that hinders the compiler from creating the Android app.
So...Be careful with privacy tools! It may be a great thing, but it can cause
problems in unexpected ways and become a real nuisance.. :-)
Post Reply