Update Android Native app to Flutter without uninstalling [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
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.
- Install the app from Google Play Store.
-
adb adb shell pm path ataberkw.packagename
to get path of base.apk. -
./adb pull base-apk-path destination-path
to get base apk - Rename
base.apk
tobase.zip
and open it. - Delete
META-INF
folder insidebase.zip
and rename it tobase.apk
back. Now you have unsigned apk. - I used this automatic apk signer but you can use manual ways too.
- Reproduce the data at Native app and now you can install signed (use same jks file) Flutter app without need of uninstall.
Ataberk
Updated on January 01, 2023Comments
-
Ataberk over 1 year
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
-
Ataberk over 2 yearsI already said package name is same. It means that I checked applicationId.
-
berkaykurkcu over 2 yearsWhat I meant was that they have to be different than each other, not the same. But I am glad you found a solution.
-
Ataberk over 2 yearsPlease read the question again. I don't want to delete the app so applicationId's already must be the same.