nativescript-community / capacitor-plugins

Community plugin for `NativeScript for Capacitor`
21 stars 3 forks source link

Android platform does not work #1

Closed SergeyMell closed 3 years ago

SergeyMell commented 3 years ago

I've added android platform to the demo project with the commands

npx cap add android
npx cap sync

according to the documentation

The project runs successfully, however, none of the actions (like change brightness or open native dialog work.

If I attach Android Studio t the process I get next logs after button click

2021-03-14 00:41:28.346 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.346 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":1000,\"log\":[\"Getter:\",\"native.openNativeModalView\"]}"}
2021-03-14 00:41:28.352 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.352 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":1000,\"log\":[\"Execute:\",\"native.openNativeModalView(\",[],\")\"]}"}
2021-03-14 00:41:28.355 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.355 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":1000,\"log\":[\"MARSHALL:\",2,\"openNativeModalView\",[]]}"}
2021-03-14 00:41:28.358 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.358 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":1000,\"log\":[\"R:\",\"openNativeModalView\",0,\"\"]}"}
2021-03-14 00:41:28.362 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.362 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":1000,\"log\":[\"Send Message\",\"{\\\"cmd\\\":2,\\\"tracking\\\":\\\"R8\\\",\\\"value\\\":\\\"openNativeModalView\\\",\\\"thisArg\\\":\\\"\\\",\\\"parentObject\\\":0,\\\"nextObjID\\\":2,\\\"extra\\\":[]}\"]}"}
2021-03-14 00:41:28.364 9295-9415/io.ionic.starter V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: -1, pluginId: NativeScriptCap, methodName: notify
2021-03-14 00:41:28.364 9295-9415/io.ionic.starter V/Capacitor: callback: -1, pluginId: NativeScriptCap, methodName: notify, methodData: {"value":"{\"cmd\":2,\"tracking\":\"R8\",\"value\":\"openNativeModalView\",\"thisArg\":\"\",\"parentObject\":0,\"nextObjID\":2,\"extra\":[]}"}
2021-03-14 00:41:28.383 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 1 6
2021-03-14 00:41:28.386 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2
2021-03-14 00:41:28.393 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 1 6
2021-03-14 00:41:28.394 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2
2021-03-14 00:41:28.403 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 1 6
2021-03-14 00:41:28.405 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2
2021-03-14 00:41:28.420 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 1 6
2021-03-14 00:41:28.421 9295-9345/io.ionic.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 2

So, it seems to be no error but nothing happens

NathanWalker commented 3 years ago

Hi @SergeyMell could you share the project on GitHub? We could take a peek to see if anything is misconfigured.

NathanWalker commented 3 years ago

Did you “npm run build:mobile” before doing the cap sync?

SergeyMell commented 3 years ago

Hi @NathanWalker. Thank you for such a quick response.

Sure, I did npm run build:mobile before. Also, I've added "@capacitor/android": "next" to package.json but this didn't help either. Here you can find a demo repo: https://github.com/SergeyMell/capacitor-plugins/tree/android-platform (android-platform branch)

I was working on rate-my-app plugin from the list of proposals so it would be great if we figure out whats the issue so I could continue ))

NathanWalker commented 3 years ago

Thanks for sample, I’ll try to take a peek tomorrow evening.

rdlabo commented 3 years ago

@SergeyMell I see. I'm sorry I didn't add Android.

You need to run npm i @nativescript/capacitor after npx cap add android. This is that post install script run and overwrite android setting file( like https://github.com/nativescript-community/capacitor-plugins/commit/8204674422ddcbe8ac58af512a02f42b7d2f0097 )

I updated this repository to add android platform. Please check this. I looks forward to add rate-my-app. Thanks

SergeyMell commented 3 years ago

Thanks a ton. It's much better for now. However, when I try to run android build I get an error

Script '/Users/mell/_contribute/capacitor-plugins/demo/angular/android/nativescript.build.gradle' line: 467
Execution failed for task ':app:cleanupAllJars'.
Could not get unknown property 'org' for task ':app:cleanupAllJars' of type org.gradle.api.DefaultTask.

But, if I comment out this line of code, the project runs successfully and works as expected

rdlabo commented 3 years ago

Mumu. I didn't get error. My Android studio version is 4.1.1. If you can't remove error after update Android Studio, or clean build, I want you will send issue to @nativescript/capacitor. Thanks.

NathanWalker commented 3 years ago

Most likely @SergeyMell after you pulled @rdlabo 's latest changes you should probably do a full clean in Android Studio to ensure gradle was properly reset.

SergeyMell commented 3 years ago

Yeah, my bad... After cleaning the project all started working like a charm.