android-js / androidjs-core-webview

Node js for android app development
26 stars 17 forks source link

Even granting WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions, the application closes unexpectedly or does not record anything. #18

Closed hardx4 closed 4 years ago

hardx4 commented 4 years ago

I cloned the repository and did some tests with writing on nodejs, without success. I don't know why, but even with permissions granted the application cannot write on the system. The same main.js works perfectly if compiled with the help of androidjs-builder on ubuntu, but the application generated on Android Studio on windows through the source of this repository does not have the same effect.

Chhekur commented 4 years ago

May be you have done something wrong because we are also using the same source to test our API's while building and it works.

did you put the node binaries at correct place ?

Chhekur commented 4 years ago

if the application is crashes then there must be some exception occurring, so you should look into the log for when and what exception is occurring that causes crashing ; )

Feel free to ask in case of any problem ; )

hardx4 commented 4 years ago

The "include" folder was placed in the "libnode" folder, as were the ".so" binaries in the "bin" folder. A strange thing that I noticed, was that even if you leave a single permission in "AndroidManifest.xml", for example: "android.permission.INTERNET". The app asks for "android.permission.CALL_PHONE" permission.

I did a lot of testing, i test just cloning the repository and putting the node and include binaries. I don't know what can be wrong. I checked everything to find out why the app was asking for "android.permission.CALL_PHONE", even without being asked for in the manifest.

Still I couldn't write to storage.

The Android Studio debug doesn't tell me anything when the app closes unexpectedly. All I know is that if I compile using androidjs-builder, the same assets work, and I can write to storage. But this gradle webview repository has not worked.

I'm using an Android Studio version 3.6.2 installed on Windows 10.

Could you help me in solving this?

hardx4 commented 4 years ago

Folder libnode

image

Folder bin

image

Folder /libnode/include/node

image

Chhekur commented 4 years ago

Can you provide me the logcat of your app ? this will help me to find out why the app is getting crashed ; )

hardx4 commented 4 years ago

I'll check where to find this, but this is my assets in the main directory:

https://www.sendspace.com/file/lgie2n main.zip

hardx4 commented 4 years ago

Debug log in Android Studio on the emulated device.

Java Printing console.pdf

When I get home, I send a debug log from a physical device.

Note that in my androidManifest.xml there is no permission for "CALL_PHONE", even so, the log presents a request.

04/14 17:00:27: Launching 'app' on Nexus 5X API 29 x86. $ adb shell am start -n "com.android.js.webview/com.android.js.webview.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 17206 on device 'Nexus_5X_API_29_x86 [emulator-5554]'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/roid.js.webvie: Not late-enabling -Xcheck:jni (already on) E/roid.js.webvie: Unknown bits set in runtime_flags: 0x8000 W/roid.js.webvie: Unexpected CPU variant for X86 using defaults: x86 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1. W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied) W/RenderThread: type=1400 audit(0.0:167): avc: denied { write } for name="property_service" dev="tmpfs" ino=7422 scontext=u:r:untrusted_app_27:s0:c137,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.android.js.webview D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so W/roid.js.webvie: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) I/WebViewFactory: Loading com.google.android.webview version 74.0.3729.185 (code 373018518) I/roid.js.webvie: The ClassLoaderContext is a special shared library. I/roid.js.webvie: The ClassLoaderContext is a special shared library. I/cr_LibraryLoader: Time to load native libraries: 2 ms (timestamps 9838-9840) I/chromium: [INFO:library_loader_hooks.cc(50)] Chromium logging enabled: level = 0, default verbosity = 0 I/cr_LibraryLoader: Expected native library version number "74.0.3729.185", actual native library version number "74.0.3729.185" W/cr_ChildProcLH: Create a new ChildConnectionAllocator with package name = com.google.android.webview, sandboxed = true W/roid.js.webvie: Accessing hidden method Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/Handler;Landroid/os/UserHandle;)Z (greylist, reflection, allowed) I/cr_BrowserStartup: Initializing chromium process, singleProcess=false E/chromium: [ERROR:filesystem_posix.cc(89)] stat /data/user/0/com.android.js.webview/cache/WebView/Crashpad: No such file or directory (2) E/chromium: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/com.android.js.webview/cache/WebView/Crashpad: No such file or directory (2) W/roid.js.webvie: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->(Landroid/content/Context;I)V (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) W/roid.js.webvie: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (greylist, reflection, allowed) I/System.out: /system I/System.out: android.permission.WRITE_SETTINGS android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_EXTERNAL_STORAGE android.permission.CALL_PHONE W/cr_media: Requires BLUETOOTH permission D/HostConnection: HostConnection::get() New Host Connection established 0xdd95add0, tid 17302 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 E/chromium: [ERROR:gl_surface_egl.cc(342)] eglChooseConfig failed with error EGL_SUCCESS D/EGL_emulation: eglCreateContext: 0xdd91afc0: maj 2 min 0 rcv 2 D/EGL_emulation: eglMakeCurrent: 0xdd91afc0: ver 2 0 (tinfo 0xc30a8b50) E/chromium: [ERROR:gl_surface_egl.cc(342)] eglChooseConfig failed with error EGL_SUCCESS D/HostConnection: HostConnection::get() New Host Connection established 0xdd956190, tid 17241 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... D/EGL_emulation: eglCreateContext: 0xdd91a360: maj 2 min 0 rcv 2 D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0) W/Gralloc3: mapper 3.x is not supported D/HostConnection: createUnique: call D/HostConnection: HostConnection::get() New Host Connection established 0xc31a0fc0, tid 17241 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 D/eglCodecCommon: allocate: Ask for block of size 0x1000 allocate: ioctl allocate returned offset 0x3ffffa000 size 0x2000 I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es W/cr_MediaCodecUtil: HW encoder for video/avc is not available on this device. D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0) D/EGL_emulation: eglCreateContext: 0xc3112360: maj 2 min 0 rcv 2 D/EGL_emulation: eglMakeCurrent: 0xc3112360: ver 2 0 (tinfo 0xc30a8b50) D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0) D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0) D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0) D/NetworkSecurityConfig: No Network Security Config specified, using platform default I/chromium: [INFO:CONSOLE(9055)] "Download the Vue Devtools extension for a better development experience: https://github.com/vuejs/vue-devtools", source: https://cdn.jsdelivr.net/npm/vue/dist/vue.js (9055) [INFO:CONSOLE(9064)] "You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html", source: https://cdn.jsdelivr.net/npm/vue/dist/vue.js (9064) W/Thread-4: type=1400 audit(0.0:168): avc: denied { ioctl } for path="/sys/kernel/debug/tracing/trace_marker" dev="tracefs" ino=29 ioctlcmd=0x5451 scontext=u:r:untrusted_app_27:s0:c137,c256,c512,c768 tcontext=u:object_r:debugfs_trace_marker:s0 tclass=file permissive=0 app=com.android.js.webview E/libc: Access denied finding property "net.dns1" D/EGL_emulation: eglMakeCurrent: 0xdd91a360: ver 2 0 (tinfo 0xc1b855d0)

Chhekur commented 4 years ago

Look at the logs it is generating error no such file or directory that's why app is getting crashed ; )

Let me know in case of any other doubt ; )

hardx4 commented 4 years ago

But the app opens, works the way it should, but stops unexpectedly, this error "no such file or directory" also occurs with the apk generated with androidjs-builder, however it does not prevent it from working. Why does the app ask for "CALL_PHONE" permission even without the "android.permission.CALL_PHONE" declared in the manifest?

The apk generated with androidjs-builder does not crash, it starts and in the process the data it can write to storage, but the same view in the gradle project does not work, this is my dilemma.

When requesting permissions on the gradle project in manifest file: <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

In the apk generated by androidjs-builder a single confirmation box appears. But in the apk generated by the gradle project, two are displayed, one to allow CALL_PHONE and the other WRITE_EXTERNAL_STORAGE, the one by CALL_PHONE should not appear, but inexplicably it does.

Screenshot_20200414-212641_Package_installer 1 Screenshot_20200414-212646_Package_installer 1

My Manifest permissions is: <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

hardx4 commented 4 years ago

The problem of the app crashing I solved, i copied the files libnode.so and the node source from my ubuntu VPS. After many tests I realized that the problem was not the permissions, so I only had one last variable that was the version of the node. I just had to copy the necessary files to the libnode folder of the Android Studio core-webview, I was a little afraid that it wouldn't work, but I was successful. The node source, copied from one of the versions installed on my nvm, version 13.6.0 and the libnode.so for the architectures copied from the .cache folder of androidjs-sdk.

The app is still asking permission for CALL_PHONE even without it being requested in the manifest, I don't know what it might be, but I believe there is a way to resolve it by removing the possibility of adding to the array of permission strings at checkAndAskForPermissionsHelper