Closed fanzhiri closed 2 years ago
change one line to fix it
node_modules\rn-update-apk\android\src\main\java\net\mikehardy\rnupdateapk\RNUpdateAPK.java
@ReactMethod
public void installApk(String filePath, String fileProviderAuthority) {
File file = new File(filePath);
if (!file.exists()) {
Log.e("RNUpdateAPK", "installApk: file doe snot exist '" + filePath + "'");
// FIXME this should take a promise and fail it
return;
}
if (Build.VERSION.SDK_INT >= 24) {
// API24 and up has a package installer that can handle FileProvider content:// URIs
Uri contentUri;
try {
//contentUri = FileProvider.getUriForFile(getReactApplicationContext(), fileProviderAuthority, file);
contentUri = FileProvider.getUriForFile(getReactApplicationContext(), fileProviderAuthority+".provider", file);
Hmm - that's not necessary for me, I'm still using this module successfully in a project on a regular basis.
android:authorities="com.BleWatch.provider"
Note that '.provider' is in the authority name, so should be present in the variable fileProviderAuthority
The example app also has always worked for me (though it's probably out of date now...) and works with the code in the repo with this provider definition
安装时闪退
10-13 12:18:33.635 16561 16617 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules 10-13 12:18:33.635 16561 16617 E AndroidRuntime: Process: com.BleWatch, PID: 16561 10-13 12:18:33.635 16561 16617 E AndroidRuntime: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.BleWatch 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:662) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:635) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:441) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at net.mikehardy.rnupdateapk.RNUpdateAPK.installApk(RNUpdateAPK.java:138) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:955) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:206) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at android.os.Looper.loop(Looper.java:296) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232) 10-13 12:18:33.635 16561 16617 E AndroidRuntime: at java.lang.Thread.run(Thread.java:930)
i check the intermediates android/app/build/intermediates/merged_manifests/release/AndroidManifest.xml then i found
"com.BleWatch.provider" should be "com.BleWatch.fileprovider"
i don't know how to fix it .