When creating apps in Android Studio which are destined to be Android System Apps, it is necessary to sign the apk file with the platform key used in the Android Source (AOSP) build.
APK files can be signed via the command line, but in most cases the user will want to add the signing as part of the Android Studio project build. In order to sign APK files in Android Studio a Keystore needs to be created from the platform keys used in the Android Source build.
Follow these steps to create a platform Keystore and add it to your Android Studio project.
Step 1 – Tools
Download the keytool-importkeypair tool from GitHub here: https://github.com/getfatday/keytool-importkeypair
Add this to your PATH for ease of use.
Step 2 – Create Keystore File
Locate the platform keys which are used in your Android Source build. These are typically located in your Android source here: build/target/product/security but for some NXP build will be located under here: device/fsl
Use the following command to create the keystore using your platforms’ key files:
keytool-importkeypair -k my.keystore -p password -pk8 platform.pk8 -cert platform.x509.pem -alias platform
Step 3 – Configure Android Studio Project Builds
Open your project in Android Studio, click on File and then Project Structure. Then in the Modules -> Signing Config section, add the Keystore to the release and debug builds.