安装新版本后,Android应用已关闭

壮心未与年俱老,死去犹能作鬼雄。这篇文章主要讲述安装新版本后,Android应用已关闭相关的知识,希望能为你提供帮助。
我有一个现有的react本机应用程序,我添加了一些功能,并希望对其进行语法更新。我的问题是安装后我的应用程序无缘无故关闭,但应用程序正在安全更新。我该如何防止这种情况
我的build.gradle

ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" }

我的本机下载部分
downloadClick = async () => { const { Model } = this.props; try { await requestPermission(Permissions.WRITE_EXTERNAL_STORAGE, trans('STORAGE_MESSAGE')); await requestPermission(Permissions.WRITE_EXTERNAL_STORAGE, trans('REQUEST_INSTALL_PACKAGES')); this.downloading(true); const filePath = `${RNFS.DocumentDirectoryPath}/com.rasapayam.apk`; RNFS.downloadFile({ // fromUrl: Model.ApkLink.value, fromUrl: "https://srv-file7.gofile.io/download/2Oyk8V/rasa-60.apk", toFile: filePath, progress: (res) => { this.setState({ progress: (res.bytesWritten / res.contentLength) }); }, progressDivider: 1, }).promise.then((result) => { this.downloading(false); if (result.statusCode === 200) { MimeIntent.openURLWithMime(filePath, 'application/vnd.android.package-archive'); } }).catch((err) => { this.downloading(false); }); } catch (err) { ToastAndroid.show(trans('VERSION_ERROR'), ToastAndroid.SHORT); this.setState({ progress: 0 }); } }

我的用于安装下载的APK的Android本机模块
@ReactMethod public void openURLWithMime(String url, String mime, Promise promise) { if (url == null || url.isEmpty()) { promise.reject(new JSApplicationIllegalArgumentException("Invalid URL: " + url)); return; } if (ContextCompat.checkSelfPermission(_context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Activity currentActivity = getCurrentActivity(); Uri contentUri = FileProvider.getUriForFile(_context, "com.rasapayam", new File( url)); Intent install = new Intent(Intent.ACTION_VIEW); install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); install.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); install.setData(contentUri); if (currentActivity != null) { currentActivity.startActivity(install); } else { getReactApplicationContext().startActivity(install); } promise.resolve(true); } }

应用清单标签上我清单的提供者
< provider android:name="androidx.core.content.FileProvider" android:authorities="com.rasapayam" android:exported="false" android:grantUriPermissions="true"> < meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_provider_paths" /> < /provider>

【安装新版本后,Android应用已关闭】我的提供者xml
< ?xml version="1.0" encoding="utf-8"?> < paths> < external-path name="external" path="." /> < external-files-path name="external_files" path="." /> < root-path name="root" path="." /> < files-path name="files" path="." /> < /paths>

答案None另一答案None

    推荐阅读