apk failed on android 12 - android

Last week I passed from a Android 10 phone to Android 12.
I had some apks decompiled/recompiled with apktool and autosigned with jarsigner, and in Android 10 I could installed them, but in Android 12 it just shows me the apk is invalid when I try to install them at the phone.
If I just decompile one and compile again, and then signed it gives me the same error. I also tryed to install it via adb install with the same result.
I also get the same doing it with Apk Edit app in the phone, so I asume with Android 12 google restringed the apk installations in the phone, but not for all of them, because I installed some apk that I had for more than 5 years and they were installed fine.
Could it be some attribute in the manifest?
I will appreciatte some light to the topic.
Regards

You problem is jarsigner. Jarsigner creates an Android APK signature v1 which is no longer accepted on modern devices.
If you want to resign an app you have to use apksigner from Android SDK as it is capable of creating an APK signature v2 and v3. It is included in build tools for each platform, for example build tools for platform API 30.
Apksigner is a Java program so it doesn't mater if you download Linux, MacOS or Windows version:
Download build-tools_r30.0.1-windows.zip
Extract from the downloaded ZIP file android-11/lib/apksigner.jar
Execute java -jar apksigner to execute Apksigner.
For a full list of commands how to generate the necessary signing keys and sign an APK please refer to this answer: https://android.stackexchange.com/a/226152/2241

Since play store started to accept AAB upload, APKs are started to build for spesific ABIs and OS versions by play store. Your problem may be caused from this situation.
For example; you can't install an apk that build for armeabi-v7a to your arm64-v8a based phone.
if this is the problem you can download appropriate apk variation from apkmirror.

Related

Update Android Native app to Flutter without uninstalling [INSTALL_FAILED_UPDATE_INCOMPATIBLE]

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
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 to base.zip and open it.
Delete META-INF folder inside base.zip and rename it to base.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.
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.

Which Flutter APK to use for installation from apk/release/ folder

When I build apk via command
flutter build apk --spli-per-abi
It generates 3 apk in: \build\app\outputs\apk\release directory
I want to know which of the APKs we will use for uploading on play store or for installing on different devices.
In addition to this, few android devices are capable of running apk named v8a and few are running v7a is there anything to do with building an apk for different versions of android? means I do i need to config SDKs so that It will run on all android versions starting from Jelly Beans 4.1
Thanks
You need to upload the 3 apk files to the Play Store.
When a client download you app, Google will provide the correct apk for the phone making the request.
please refer to this post :
How to build signed apk from Android Studio for Flutter
it will generate fully signed apk reales and u can upload it to google play store to work on all devices

Why is new apk not installed when older app is built on Android Studio or installed from Play Store?

I am trying to build apk for Chinese users. But I found some issue.
When the previous app is built from
Play Store
Android Studio
The apk file doesn't complete installation. And says it's not installed.
However, when I install older one by adb install my_app.apk or download the apk file from the internet and open/install, it installs successfully.
All the apk files has signed key(except for Android Studio build one). And I have no idea what's the problem. Or should it work & Am I wrong? I just tested Play Store one as Internal App Sharing. Since I can't test it out in the real market.

Android Signed and Unsigned Export Error

I have an developed an android app with minimum API level 9 and Maximum 4.4 Kitkat. When i intent to export the app i tried both of the options provided in Eclipse ADT bundle.I tried the unsigned export it compiled and gave a APK file. I copied the APK file to the SD card and tried to install on my device it said application did not installed..I can't figure out the problem?
Most probably it is caused by different signatures. Try installing it from console, so you can see deatiled error message.
Un-install your app from your phone first, then try.
You cannot install the built app (APK) if you have the debug (Eclipse) version on your phone.
The package names etc conflict, while it thinks the apps are different, due to the test/release signatures so will not let you install it again.

Signing APK by commandline

I am developing android applications with Eclipse and the Android SDK. For testing the app on a device it is pretty embarrasing to do the same job every time:
Android Tools
Export Signed Application Package
Select project
Select keystore
Use password
Select alias
Use password
Select output path & file
After that using commandline and adb to uninstall previous version of the installed app. Then installing new version of the app.
As this way is mich too long I wanted to script the whole action, but the jarsigner is always stopping with same error and I can't sign the apk.
unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 761 but got 763 bytes)
At this point I am pretty confused. The jarsigner is from JDK 1.6.0.26. Eclipse is at Version 3.6.2. Android SDK is complete up-to-date. I am working under Windows Vista 32-bit.
Has anyone similar problems with the jarsigner or can give me some tips?!
Why don't you just debug the app on your phone?
This is how to do it:
First, download and install your phone's drivers (find via a Google search)
Debug the project in eclipse as you would on an emulator in eclipse, but when eclipse tells you to choose a device, pick your phone.
This way, you won't have to export the app, and you can debug on a decent device - i.e. not an emulator.

Categories

Resources