Open source: In this article, the author of ReactNative integration of Baidu voice synthesis components library, today by checking the issues on Github about the react-native source baidu- VTTS, A friend mentioned a bug and gave a specific error
Excuse me, "Java. Lang. String com. Wayne. Baiduvoice. Util. OfflineResource. GetTextFilename ()" is null what reason be?Copy the code
12-26 16:37:12. 311, 14862-14885 / com. Anlint. Weightapp E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.anlint.weightapp, PID: 14862 java.lang.NullPointerException: Attempt to invoke virtual method'java.lang.String com.wayne.baiduvoice.util.OfflineResource.getTextFilename()'on a null object reference at com.wayne.baiduvoice.VoiceUtils.getParams(VoiceUtils.java:175) at com.wayne.baiduvoice.VoiceUtils.initialTts(VoiceUtils.java:83) at com.wayne.baiduvoice.VoiceUtils.init(VoiceUtils.java:65) at com.wayne.baiduvoice.RNBaiduvoiceModule.initBaiduTTS(RNBaiduvoiceModule.java:32) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26) at android.os.Looper.loop(Looper.java:148) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225)
at java.lang.Thread.run(Thread.java:818)
Copy the code
A close review of our open source library code reveals that Android10 has a problem with access to external storage for apps. Google also mentions this problem in the development documentation, as described below.
To help users better manage their files and reduce clutter, apps targeting Android 10 (API level 29) and later are granted partitioned access to external storage by default. Such applications can only see the directory of the application of proprietary (through the Context. GetExternalFilesDir () access), and certain types of media. Unless your application needs to access files that reside in an application’s proprietary directory and outside of MediaStore, it is best to use partitioned storage.
This issue has been fixed and published to the NPM repository. You can update the ReactNative project dependencies by using the following command line to resolve this bug.
yarn add react-native-baidu-vtts
Copy the code
Thank you for your support. I will make more efforts to contribute more to the open source community in the future.
Welcome to follow my official account: Jun Wei said. Sharing the ups and downs of development technology, professional life and programming. Oh right, this number Lord, still like to send red envelope 😀.