During the signature verification of your Ionic 3 package, you get warnings on version files. This guide will help you to resolve this issue... :)

When you want to publish your app in Play Store, you have to sign it.

In order to do so, many people use a guide, for instance this one. After executing the command apksigner verify YourApp.apk, you obtain the following warnings:

WARNING: META-INF/android.arch.lifecycle_runtime.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_animated-vector-drawable.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_appcompat-v7.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_cardview-v7.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_customtabs.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-compat.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-core-ui.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-core-utils.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-fragment.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-media-compat.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-v4.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-vector-drawable.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.

Actually, building Ionic App put version files in META-INF but, despite many researches, I still don't know why.

After some analyzis, it appears that this files do not impact the App: they only give informations. The better thing to do to resolve issue is moving files files outside of META-INF, as it isrequested by the warning messages.

Preparation of build

As it is described in Ionic guide, execute the following commands in order to have an unsigned release App:

ionic cordova build android --prod --release

Operation: Move files

This chapter is written for Windows users but you can adapt it for your needs.

An APK file is a ZIP file that can be treated as a JAR package (See chapter 3 of document); In this document, the structure of the APK file is described and META-INF directory is used to host the package manifest file and code signatures.

So, we can use the JAR tool to unzip, move files and zip a new package.

I recommand you to set the commands in a bat file.

1. Unzip contents

To unzip contents, execute the following commands:

 copy %unsigned_apk_release% %temp_path%\temp.apk
 cd /d %temp_path%
 call "C:\Program Files\Java\jdk1.8.0_131\bin\jar" xf %temp_path%\temp.apk
 del %acm_temp_path%\temp.apk

%unsigned_apk_release% is the package build in the previous chapter.
%temp_path% is a temporary directory to do operations.
jdk1.8.0_131 shall correspond to your JDK version.

You obtain an extracted package in %temp_path%

2. Move files

To move files, execute the following standard Windows commands:

 mkdir Versions
 for %%g in (META-INF\*.version) do (
   echo Move %%g to Versions\%%~nxg
   copy %%g Versions\%%~nxg
   del %%g
 )

All files .version from META-INF are moved to Versions.

3. Zip new package

To create a new APK package, execute the following command:

 call "C:\Program Files\Java\jdk1.8.0_131\bin\jar" cf app-unsigned-clean.apk *

The new package app-unsigned-clean.apk is created and can be used to sign contents before publishing it.

Operation: Sign package

Now, the package is cleaned. You can follow this guide since step 2.

Using the tool apksigner instead of jarsigned is just a personal choice, because the same tool is used to sign package and verify signatures.

That's all for this article!

See you for the next ! :)

Previous Post Next Post


Comments

Gravatar

clemdesign

21, September 2018 16:26:28
Hi Jaydeep, all files with extension ".version" shall be moved to "Versions" parent directory. Second step is a batch routine for Windows to do this operation.
Gravatar

Jaydeep

21, September 2018 15:00:26
i did't understand your second step, where i put or paste explain in detail if possible...much confusing for me

Add a comment