Instructions for creating an Android app

Everything else that doesn't fall into one of the other categories.
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Instructions for creating an Android app

Post by hoerbie »

Peter, our SB god, thanks for this tip, I think it will be really helpful with the next upcoming problems!

Stefan, what version of SB and what Java do you use? I use SB 2.32Beta1 with Java jdk-8u321 on Win 11 Pro 64 for compiling, but I'm actually at "only" 10000 code lines, mostly SB and some JS as solution for missing things. Since my changes of the device-plugin I don't have any problems, and I also include other cordova plugins with own changes for bluetooth (also hardware-near).

DeviceAlwaysOn(*) is also an SB command like DeviceInfo(*), that seems to need the device-plugin.
Stefan
Posts: 160
Joined: Mon Feb 05, 2018 9:44 pm

Re: Instructions for creating an Android app

Post by Stefan »

Ich habe tatsächlich etwas gefunden:

if("undefined"==typeof Spider)var Spider={};spider.system={batteryEventRegistered:0,batteryLevel:-1,defaultBrightness:0.5};function spider_InitSystem(){window.cordova&&cordova.plugins.brightness.getBrightness(function(a){spider.system.defaultBrightness=a;console.log("night: "+a)})}function spider_ElapsedMilliseconds(){return(new Date).getTime()}function spider_CountProgramParameters(){var a=location.search.substring(1);return 0<a.length?spider_CountString(a,"&")+1:0}
function spider_ProgramParameter(a){var d=location.search.substring(1);return 0<=a&&a<spider_CountProgramParameters()?decodeURI(spider_StringField(d,a+1,"&")):""}function spider_BatteryLevel(){window.cordova&&!spider.system.batteryEventRegistered&&(spider.system.batteryEventRegistered=1,window.addEventListener("batterystatus",function(a){spider.system.batteryLevel=a.isPlugged?-2:a.level},!1));return spider.system.batteryLevel}
function spider_DeviceInfo(a){if(window.cordova)switch(a){case 0:return device.model;case 1:return device.platform;case 2:return device.uuid;case 3:return device.version;case 4:return device.manufacturer;case 5:return device.serial}return""}function spider_VibrateDevice(a){window.cordova&&navigator.vibrate(a)}function spider_DeviceBrightness(a){window.cordova&&(-1===a?cordova.plugins.brightness.setBrightness(spider.system.defaultBrightness):cordova.plugins.brightness.setBrightness(a/100))}
function spider_DeviceAlwaysOn(a){window.cordova&&cordova.plugins.brightness.setKeepScreenOn(0!==a)}function spider_LoadScript(a,d,b){"undefined"==typeof b&&(b=0);var c="text";0===b&&(c="script");$.ajax({url:a,dataType:c}).done(function(c,f,e){1==b&&$("<style></style>").appendTo("head").html(c);d(a,1)}).fail(function(b,c,e){d(a,0)})};
Allerdings kann ich das nicht in meinem Spider-Code entdecken.

Ich habe Spiderbasic 2.32 beta 1
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Instructions for creating an Android app

Post by Peter »

Stefan wrote: Sat Jul 23, 2022 9:24 pm Ich habe tatsächlich etwas gefunden:
lt. Deinem Schnippsel könnten es folgende Befehle sein: BatteryLevel(), DeviceInfo(), VibrateDevice(), DeviceBrightness(), DeviceAlwaysOn().

Könnten, nicht müssen. Kann auch sein, dass ein anderer Befehl die Cordova-Funktionen einbindet.
Stefan
Posts: 160
Joined: Mon Feb 05, 2018 9:44 pm

Re: Instructions for creating an Android app

Post by Stefan »

I don't use any of that.
Is it possible to issue Cordova with one command?
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Instructions for creating an Android app

Post by hoerbie »

Stefan, sorry but there really must be other SB commands in your code, that trigger the automatic include of the device-plugin.
I‘ve checked my spiderbasic.js file, and there is no cordova in it.
Do you use geolocation or any other things, that are not really „basic“?

If you really have time, you could compile a web app with SB, set up a cordova project manually, copy your web app to the project and compile it manually in cordova to android.
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Instructions for creating an Android app

Post by hoerbie »

Just tested some of the SB examples compiling for Android, because I don't want new problems for my app, and found out:
the Screen.sb example triggers the same plugin error.
Stefan, do you use the Screen/Frame/Buffer/Sprite features in your app? Maybe you can try with the example, what function there is the problem?
Stefan
Posts: 160
Joined: Mon Feb 05, 2018 9:44 pm

Re: Instructions for creating an Android app

Post by Stefan »

Surprise, surprise, the problem is ElapsedMilliseconds()

Here is the solution:

Code: Select all

Procedure.d ElapsedMilliseconds2()
   Protected ms.d
   ! v_ms = (new Date).getTime()
   ProcedureReturn ms
EndProcedure
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Instructions for creating an Android app

Post by hoerbie »

Oh my god, I'm speechless, that such a basic function kills the Android compile.....
Stefan
Posts: 160
Joined: Mon Feb 05, 2018 9:44 pm

Re: Instructions for creating an Android app

Post by Stefan »

In the help under system you will probably find all the commands that can cause trouble:

BatteryLevel()
CountProgramParameters()
DeviceAlwaysOn()
DeviceBrightness()
DeviceInfo()
ElapsedMilliseconds()
LoadScript()
LoadStyle()
ProgramParameter()
VibrateDevice()
Post Reply