User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

plugins:building_an_apk

Building an APK

The DroidScript ApkBuilder plugin allows you to export your apps to standard Android Package files (APK files). You can then distribute your apps to your friends or upload your them to Google Play for the whole world to try!

Usage

Once the ApkBuilder plugin is downloaded, you can create APK files by long pressing on your app icon in DroidScript and selecting the 'Build APK' option.

File paths

It is important to use relative file paths in your JavaScript source code to load images, sounds and external scripts etc, because these files are copied into the APK file as internal assets during the build process. Remember the “/sdcard/DroidScript” folder will probably not exist on someone else's mobile device.

So you should do this:-

img = app.CreateImage( "Img/myface.png" );

not this:-

img = app.CreateImage( "/sdcard/DroidScript/MyApp/Img/myface.png" );

Extracting assets

If your app is running a web server or streaming video from assets, then you will need to extract these assets from your APK to the internal sdcard when your app is first run. These assets can then be served/streamed from the there instead, because assets cannot be served or streamed from inside an APK.

Another reason you might want to extract assets to the device's internal sdcard, is when you need to modify them in some way or allow the user to modify them at run time. For example you might have a template settings file or database file that should be extracted when the app is first run. You can handle the extraction of assets using the app.IsNewVersion() and app.ExtractAssets() methods.

Using a build.json file

If you create a file called 'build.json' at the top level of your project, then you will be able to control certain aspects of the build process, such as the 'minSdkVersion' setting in the manifest, which sets the minimum version of Android that your app will run on.

{
	"manifest" : 
	{ 
		"minSdkVersion" : 18,
		"targetSdkVersion" : 21,
		"debuggable" : false,
		"removePermissions" : "WRITE_EXTERNAL_STORAGE, ACCESS_WIFI_STATE",
		"homeScreen":false,
		"pathPattern":".*\\.jpg,.*\\.txt"
	}
}

Note: This file is optional and not required for building APKs

If you release your app on Google Play, the 'minSdkVersion' setting will control whether people with older phones can see your app in the store. If your app does not perform well on older versions of Android, then it is usually a good idea to make it unavailable for older phones or you will get lots of negative ratings and people will avoid your app. There may also be features such as Bluetooth 4.0 which are unavailable on older versions of Android.

DroidScript uses a simplified permissions model and scans your code looking for the required Android permissions, but you may want more fine-grain control of these permissions, so the 'removePermissions' setting allows you to explicitly remove Android permissions from your APK.

See the Android SDK docs for for a full list of permissions.

The 'homeScreen' setting is only used for creating home screen launchers apps, public kiosks and machine control type apps which totally take over the Android device, so don't use this option unless you know what you are doing!

If you want your app to handle certain types of file when the user tries to open them or use the 'Share via' option, then the 'pathPattern' setting allows you to specify which file types your app accepts. For example, if you were writing a text editor, then you would use the *\\.txt pattern.

See the 'Shared Data' and 'Receive Intent' samples in DroidScript for demos of how to handle file and text in your app.

The 'debuggable' setting is intended for advanced users and allows your installed app to be debugged via the Android Debug Bridge. This setting defaults to false and should never be set to true in public releases of your app.

Typical build.json file:-

{
	"manifest" : 
	{ 
		"minSdkVersion" : 19,
		"targetSdkVersion" : 21,
	}
}
plugins/building_an_apk.txt · Last modified: 2018/12/30 13:28 (external edit)