androidjs icon indicating copy to clipboard operation
androidjs copied to clipboard

reduce SIZE

Open ghost opened this issue 6 years ago • 11 comments

I noticed that even a very basic App will lead to an at-least 52MB APK file. Is it really necessary that, the built apk file so much huge be? Is it possible to diminish the SIZE?

ghost avatar Oct 04 '19 11:10 ghost

It's because the node has to be embedded in the app. That's around 30MB just for pc, so it could be bigger for android support. Also maybe you have some images, scripts etc, that might add space too.

danbulant avatar Oct 23 '19 17:10 danbulant

Hey, we have created a slack channel for support & discussion: join here

Chhekur avatar May 01 '20 19:05 Chhekur

What is the solution for this problem ? I want to reduce my apk size. Is there any solution for this?

Bhahirathan avatar Jul 21 '20 09:07 Bhahirathan

This is the only problem preventing me from adopting androidjs to create my apps

appsdevpk avatar Aug 13 '20 19:08 appsdevpk

Apk webview only (#144) feature would be one of the solution.

Other one would be some sort of reusing already existing nodejs installation (?). Some sort of dependency on base/ shared app with nodejs environment for every androidjs webview app (many to one)? I think it would be nice feature.

PawelSuwinski avatar Dec 04 '20 11:12 PawelSuwinski

@PawelSuwinski we had thought of the same approach but it has some complexity in UX and security-wise that's why we didn't implement this that way.

Chhekur avatar Dec 04 '20 13:12 Chhekur

@Chhekur OK, so what about another approach to meet this size reducing requirement in a halfway between webview-only-SDK and with-node-SDK by implementing some simplified version of child_process.spawnSync to execute system commands?

There are a few useful base utils in android /system/bin/ (for example toybox) and shell poweruser can accomplish quite a bit of these in as part of backend processing especially in conjunction with app API.

For example:

// trigger VIEW actiton by ActivityManager
const file = app.getPath('downloads') + '/some/file.txt';
{pid,  stdout, stderr, status, error} =  app.exec('am', [...'start --user 0 -a android.intent.action.VIEW -d'.split(' '), file]);

// read file 
{...} = app.exec('cat', [file]);

// save file
{...} = app.exec('cat > ', [file], { input: myData, shell: true});

And so on... leaving with-node-SDK version to more advanced tasks and backend processing.

PawelSuwinski avatar Dec 05 '20 09:12 PawelSuwinski

@Chhekur OK, so what about another approach to meet this size reducing requirement in a halfway between webview-only-SDK and with-node-SDK by implementing some simplified version of child_process.spawnSync to execute system commands?

There are a few useful base utils in android /system/bin/ (for example toybox) and shell poweruser can accomplish quite a bit of these in as part of backend processing especially in conjunction with app API.

For example:

// trigger VIEW actiton by ActivityManager
const file = app.getPath('downloads') + '/some/file.txt';
{pid,  stdout, stderr, status, error} =  app.exec('am', [...'start --user 0 -a android.intent.action.VIEW -d'.split(' '), file]);

// read file 
{...} = app.exec('cat', [file]);

// save file
{...} = app.exec('cat > ', [file], { input: myData, shell: true});

And so on... leaving with-node-SDK version to more advanced tasks and backend processing.

some error happened,app.exec is right?

$("#open").on("click", ()=>{
	var params = `start --user 0 -a android.intent.action.VIEW -d ${link}`.split(' ')
	app.exec('am', params);	
})

THROFHR avatar May 27 '22 19:05 THROFHR

And what logcat says?

PawelSuwinski avatar May 30 '22 06:05 PawelSuwinski

app.exec is not a function

THROFHR avatar Jun 08 '22 16:06 THROFHR

I am afraid that this feature was not merged yet and is not present at dist version: https://github.com/android-js/android-native-apis/pull/15

PawelSuwinski avatar Jun 10 '22 06:06 PawelSuwinski