pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 587 forks source link

app stopping when using cordova-plugin-file-opener2 for opening apk file in android 8 #245

Closed shomid closed 5 years ago

shomid commented 5 years ago

in my app(ionic project) for updating app downloading apk file(new version) then when opening apk file downloaded with cordova-plugin-file-opener2(2.1.4) app stopping(android 8). this work fine in android 4.4,5,6

ionic info :

ionic (Ionic CLI)             : 4.7.1 (/usr/lib/node_modules/ionic)
Ionic Framework               : @ionic/angular 4.0.0-rc.0
@angular-devkit/build-angular : 0.11.4
@angular-devkit/schematics    : 7.1.4
@angular/cli                  : 7.1.4
@ionic/angular-toolkit        : 1.2.2

Cordova:

  cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
  Cordova Platforms     : android 7.1.4
  Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.0.0, (and 15 other plugins)

System:

  Android SDK Tools : 26.1.1 (/home/omid/programming_tools/android-sdk)
  NodeJS            : v10.15.0 (/usr/local/bin/node)
  npm               : 6.4.1
  OS                : Linux 4.18
daifeil commented 5 years ago

My app also have problem when opening apk in android 8. But it didn't stop the app, and no error occurred. It returned 'OK' in promise. Just not opening the apk file

shomid commented 5 years ago

I solved my problem with adding code below in config.xml file:

<config-file parent="/manifest" target="AndroidManifest.xml" 
        xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</config-file>
shnist commented 5 years ago

as per @shomid last comment, a config update is needed in your config.xml file to support opening APK files. Instructions are in the readme https://github.com/pwlin/cordova-plugin-file-opener2#android-apk-installation-limitation

abcfy2 commented 5 years ago

Thanks @shnist.

But I have another issue. When I update my app by using file opener2 open apk file in ionic, it's not showing install success page. And I find so many people have the same issue. Like

And they all have the same solution, modify io.github.pwlin.cordova.plugins.fileopener2 and add intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); manually.

Would you please add the patch from the red lines ? https://blog.csdn.net/ducp123/article/details/80421123