Nativescript: [HELP] File-system module error on android nougat 7.1.2

Created on 19 Dec 2017  路  8Comments  路  Source: NativeScript/NativeScript

I have an error when I use file-system module on android nougat 7.1.2. By the way, what is the solution for this problem?

``` An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException:
Calling js method onStart failed

TypeError: Cannot read property 'length' of null
File: "file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/file-system/file-system.js, line: 417, column: 12

StackTrace:
Frame: function:'FileSystemAccess.enumEntities', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/file-system/file-system-access.js', line: 325, column: 35
Frame: function:'FileSystemAccess.eachEntity', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/file-system/file-system-access.js', line: 47, column: 14
Frame: function:'Folder.eachEntity', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/file-system/file-system.js', line: 419, column: 25
Frame: function:'masuk', file:'file:///data/data/org.nativescript.mads/files/app/views/filemanager/file.js', line: 17, column: 15
Frame: function:'exports.onLoaded', file:'file:///data/data/org.nativescript.mads/files/app/views/filemanager/file.js', line: 112, column: 5
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23
Frame: function:'Observable._emit', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 120, column: 18
Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 188, column: 14
Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 62, column: 35
Frame: function:'PageBase.onLoaded', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 91, column: 35
Frame: function:'Page.onLoaded', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 105, column: 35
Frame: function:'DialogFragmentImpl.onStart', file:'file:///data/data/org.nativescript.mads/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 53, column: 29

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1084)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:966)
at com.tns.Runtime.callJSMethod(Runtime.java:953)
at com.tns.Runtime.callJSMethod(Runtime.java:937)
at com.tns.Runtime.callJSMethod(Runtime.java:929)
at com.tns.gen.android.app.DialogFragment_frnal_ts_helpers_l58_c38_DialogFragmentImpl.onStart(DialogFragment_frnal_ts_helpers_l58_c38_DialogFragmentImpl.java:17)
at android.app.Fragment.performStart(Fragment.java:2379)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1027)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.BackStackRecord.run(BackStackRecord.java:816)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:483)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6186)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) ```
android

All 8 comments

Hi @dyazincahya,
Thank you for contacting us.
We reviewed your case, however, the given information is not enough to investigate your issue?
Could you send us a sample project and more info about your environment:(CLI modules, node, npm )?

In the future, please follow our template, while logging new issue. There it is described, what is the needed info, which will also help us while investigating the problem.
.

"In the future, please follow our template, while logging new issue. There it is described, what is the needed info, which will also help us while investigation of the problem." ==> Okay :D

Sample part from my app (choose file) : https://github.com/dyazincahya/choosefile-nativescript-sample

When i try on emulator my app runs smoothly, but when i run in the real device my app error or sometimes can not permissions

Hi @dyazincahya,
Thank you for the attached project, however, there are some missing resources in the project:

  • shared/config
  • shared/navigation-vm
    , which prevent us from building the project and researching the issue.
    Please send us the missing files.

That file there is in my project (shared/config & shared/navigation-vm).
I am sorry, the file I uploaded is still lacking, Later I will to upload that file when i arrived in my office

Hi @tsonevn
I was updated my repository

Hi @dyazincahya,
I reviewed your case and found that the issue is related to the newer Android device and the fact that you do not have access to the System folder as it was in the old devices.
Regarding that when you try to access / dir the file system module will return an undefined object, which will lead to the above-mentioned error.

More about the accessible directories could be found here.
I also reviewed several File Manager apps written with native code and found that they allow you to access only the internal storage on the latest Android versions. Regarding that, I would suggest replacing / with /sdcard. This will give you access to the internal storage on the older and the newer Android versions.

For your convenience, I am attaching a sample project.
Archive.zip
Let me know if this helps or if I could assist you further.

Hi @tsonevn,

Solved, case closed, thank you for your help :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings