-
-
Notifications
You must be signed in to change notification settings - Fork 197
openFile hangs #4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was having this problem too. Make sure you have a file provider defined in your AndroidManifest.xml that helped me:
^^ that is the androidx version (nativescript 6+) if you are using nativescript < 6 use something like this
don't forget to fill in the |
@DanLatimer, thanks for the hint. My manifest file starts with:
Hence I used "PACKAGE" as the (placeholder) for the package name.
When building I get an error that xml/provider_paths.xml is missing., I added this file Android/main/res/xml/provider_paths.xml with the following content:
Now it worked. I hope this can help other people. I suggest your and mine additions are added to the plugin ?! |
Thank you for sharing this! I'm closing this thread, you can log a separate issue in tns-core-modules and discuss if your additions can be added. |
Also, if you are saving files to
dp |
After upgrading to latest version of nativescript and node openFile hangs with the following log:
Error: Error in openFile: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:605) androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579) androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417) com.tns.Runtime.callJSMethodNative(Native Method) com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242) com.tns.Runtime.callJSMethodImpl(Runtime.java:1122) com.tns.Runtime.callJSMethod(Runtime.java:1109) com.tns.Runtime.callJSMethod(Runtime.java:1089) com.tns.Runtime.callJSMethod(Runtime.java:1081) com.tns.gen.java.lang.Object_vendor_14095_32_ClickListenerImpl.onClick(Object_vendor_14095_32_ClickListenerImpl.java:18) android.view.View.performClick(View.java:6600) android.view.View.performClickInternal(View.java:6577) android.view.View.access$3100(View.java:781) android.view.View$PerformClick.run(View.java:25912) android.os.Handler.handleCallback(Handler.java:873) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loop(Looper.java:193) android.app.ActivityThread.main(ActivityThread.java:6923) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) [file:///data/data/org.nativescript.tester/files/app/vendor.js] Error: Error in openFile: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:605) androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579) androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417) com.tns.Runtime.callJSMethodNative(Native Method) com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242) com.tns.Runtime.callJSMethodImpl(Runtime.java:1122) com.tns.Runtime.callJSMethod(Runtime.java:1109) com.tns.Runtime.callJSMethod(Runtime.java:1089) com.tns.Runtime.callJSMethod(Runtime.java:1081) com.tns.gen.java.lang.Object_vendor_14095_32_ClickListenerImpl.onClick(Object_vendor_14095_32_ClickListenerImpl.java:18) android.view.View.performClick(View.java:6600) android.view.View.performClickInternal(View.java:6577) android.view.View.access$3100(View.java:781) android.view.View$PerformClick.run(View.java:25912) android.os.Handler.handleCallback(Handler.java:873) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loop(Looper.java:193) android.app.ActivityThread.main(ActivityThread.java:6923) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
I tested with a newly created project and test program for android:
TS:
`import { EventData } from "tns-core-modules/data/observable";
import { Page } from "tns-core-modules/ui/page";
import {FileSystemAccess} from "tns-core-modules/file-system/file-system-access"
const fsa=new FileSystemAccess()
import { openFile} from "tns-core-modules/utils/utils"
class ViewModel {
onTest(){
let path="/storage/emulated/0/Download/test.txt"
fsa.writeText(path,"tester")
console.log(fsa.fileExists(path))
openFile(path)
}
}
export function navigatingTo(args: EventData) {
const page = args.object;
page.bindingContext = new ViewModel()
}
`
XML:
<Page navigatingTo="navigatingTo"> <Button text="Test" tap="{{onTest}}"/> </Page>
tns doctor shows:
√ Your ANDROID_HOME environment variable is set and points to correct directory. √ Your adb from the Android SDK is correctly installed. √ The Android SDK is installed. √ A compatible Android SDK for compilation is found. √ Javac is installed and is configured properly. √ The Java Development Kit (JDK) is installed and is configured properly. √ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure. √ Getting NativeScript components versions information... √ Component nativescript has 6.0.1 version and is up to date. √ Component tns-core-modules has 6.0.1 version and is up to date. √ Component tns-android has 6.0.0 version and is up to date. √ Component tns-ios has 6.0.1 version and is up to date.
The text was updated successfully, but these errors were encountered: