Norman
Norman

Reputation: 3167

flutter build apk --split-per-abi: what is the difference between app-armeabi-v7a-release.apk and app.apk

When I run flutter build apk --split-per-abi I get 4 files in the directory flutter-apk:

  1. app-arm64-v8a-release.apk,
  2. app-armeabi-v7a-release.apk,
  3. app-x86_64.apk,
  4. app.apk.

I already know that the first three apks are due to different cpu-architectures/ instructionsets. On my android-phone I am able to install app-armeabi-v7a-release.apk and app.apk. So are they the same? Where is the difference?

Upvotes: 17

Views: 8942

Answers (4)

Mashood .H
Mashood .H

Reputation: 1782

app.apk

it's a universal APK that contains code for all available instruction sets (armeabi-v7a, arm64-v8a, and x86_64). This means that the app can run on any device regardless of its CPU architecture.but of course it will increase the file size of your app and reduce optimisation

app-armeabi-v7a-release.apk

it's specifically built for devices with the armeabi-v7a CPU architecture. This APK is optimized to run more efficiently on devices with this architecture. The other two APK files (app-arm64-v8a-release.apk and app-x86_64.apk) are also optimized for> their respective CPU architectures.

when to use split command ?

it's pretty straight forward when you are unaware about your device architecture simply build the apk with flutter build apk otherwise use splite command

Upvotes: 1

LOLWTFasdasd asdad
LOLWTFasdasd asdad

Reputation: 2913

Taken from the flutter GitHub repository:

When running a flutter app in debug mode, the dart code is compiled just of time (JIT), making it possible to use features like hot reload/restart. In release mode, the code is compiled ahead of time (AOT) to native code. This mode is better for performances and results into a smaller app; it also removes stuffs that are only using in development mode. The app-debug.apk file is just the build you get when running/compiling your app in debug mode.

app.apk -> AOT

app-debug.apk -> JIT

When you build your app using --split-per-abi param, it results into 3 separated files as mentionned in the docs, located it PROJECT_SRC/build/app/outputs/apk/prod/release/. These files are the optimized build for each android architecture


As mentioned from the answer you can see that the difference is the used compilation concept (if you want to read more about it I think this is a good start).

I'd assume that app.apk and app-debug.apk are then used to be furthermore optimized for their specific target platform and are therefore kept as a neccessary side product. I don't think there is any particular reason otherwise to keep those.

Upvotes: 0

UnnamedXAer
UnnamedXAer

Reputation: 342

My search for an answer to the same question as yours ended without a satisfactory result.

Then I came up with the idea of using SHA-256 checksums for file equality verification.

If you know the checksum of the original file, you can run a checksum or hashing utility on it. If the resulting checksum matches, you know the file you have is identical. [from here]

We can see from the hashing results that file app.apk is equal to file app-armeabi-v7a-staging-release.apk based on the hashing of all of the apks.

  13:10:25  qrcode_keeper  master  +1 ~1  ﮫ 39ms                             Path
➜ Get-FileHash build\app\outputs\flutter-apk\app.apk                                   ----
                                                                                       C:...
Algorithm       Hash
---------       ----
SHA256          4349EF321BDE25DB32FED4D3C8E0BB265BF5BF6595767F20C2D43B8BBD5BDF13      


  13:10:26  qrcode_keeper  master  +1 ~1  ﮫ 80ms                             Path
➜ Get-FileHash build\app\outputs\flutter-apk\app-armeabi-v7a-staging-release.apk       ----
                                                                                       C:...
Algorithm       Hash
---------       ----
SHA256          4349EF321BDE25DB32FED4D3C8E0BB265BF5BF6595767F20C2D43B8BBD5BDF13      


  13:10:31  qrcode_keeper  master  +1 ~1  ﮫ 72ms                             Path
➜ Get-FileHash build\app\outputs\flutter-apk\app-arm64-v8a-staging-release.apk         ----
                                                                                       C:...
Algorithm       Hash
---------       ----
SHA256          AE4DDBBCFDD5A0AF273DDBE2A1CF4C56513D63C1D5A2F151EF973855FA190E0B      


  13:10:38  qrcode_keeper  master  +1 ~1  ﮫ 82ms 
➜ Get-FileHash build\app\outputs\flutter-apk\app-x86_64-staging-release.apk           

Algorithm       Hash
---------       ----
SHA256          1D6EBAAA82DF6984C352E4B06D0300386A26EF19A7DE4CB476105060FC74938B  

Upvotes: 0

Senay Gebre
Senay Gebre

Reputation: 11

I think you first run flutter build apk that generates the apk app.apk, this apk will run almost to all architectures (decides by itself). Then you again run the command flutter build apk --split-per-abi. which means you get the two command results both. Just try to delete all apk output files and re-run the command flutter build apk --split-per-abi, I hope you will get only three files.

Upvotes: 1

Related Questions