Home > Blockchain >  Update Android Native app to Flutter without uninstalling [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
Update Android Native app to Flutter without uninstalling [INSTALL_FAILED_UPDATE_INCOMPATIBLE]

Time:09-21

I have an app on Google Play Store. I rewrote that app on Flutter but not published yet. I don't want users to lose their data on update. To solve this I want to write a conversion system but I need to be able to reach old database when Flutter app launches.

Android system doesn't allow two different app with same package name installed. When I try to install Flutter app on a device that has Native app, Visual Studio debugger gives [INSTALL_FAILED_UPDATE_INCOMPATIBLE] error. It uninstalls Native app and installs Flutter app so I won't be able to reach Native app's sqlite database.

Also the reason why I use the Google Play version is I lost my old project's latest update files. There is no fraud no worries :)

What I tried:

  • Make Flutter app's package name same as Native app's.
  • Sign debug version with Native app's keystore file.
  • Give Flutter app a higher version than Native app.

After steps I did above, first build stuck at Running Gradle task 'assembleDebug'.... Output stays like this (I waited several times, maximum for 30 mins):

Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
✓  Built build/app/outputs/flutter-apk/app-debug.apk.

If I clean project, it builds in 30 seconds but uninstalls Native app with this output:

Running "flutter pub get" in projectname_2...
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install /Users/xxxxxx/projectname/build/app/outputs/flutter-apk/app.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package ataberkw.projectname signatures do not match previously installed version; ignoring!]
Uninstalling old version...
W/FlutterActivityAndFragmentDelegate(11073): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Connecting to VM Service at ws://127.0.0.1:58745/lUE5l2_VlN4=/ws

CodePudding user response:

Have you checked your app's applicationId's? If they are the same, that might make OS think that you are installing the same app again. In Flutter, your applicationId is located in android\app\build.gradle file. You can address here for documentation.

CodePudding user response:

I realized that Google Play has it's own signature system additional to your keystore signing. Things may not exactly what I said but consequently apks Google Play and apks signed with your keystore doesn't have the same certificate. After this realization I came up with a solution.

  1. Install the app from Google Play Store.
  2. adb adb shell pm path ataberkw.packagename to get path of base.apk.
  3. ./adb pull base-apk-path destination-path to get base apk
  4. Rename base.apk to base.zip and open it.
  5. Delete META-INF folder inside base.zip and rename it to base.apk back. Now you have unsigned apk.
  6. I used this automatic apk signer but you can use manual ways too.
  7. Reproduce the data at Native app and now you can install signed (use same jks file) Flutter app without need of uninstall.
  • Related