Building an Android APK with same certificate as t

2019-02-16 04:45发布

问题:

I'm trying to make a system app work. Here's what I have:

An OEM OMAP platform with full 4.4.2 source code. I've built the system and loaded on my platform using Ubuntu 14.04. That all works.

Now, there is an app from the OEM which directly accesses the hardware (DSP, I2C, UART) etc. The original APK that came from the OEM works on my platform.

I built the exact same app using make command (not using Eclipse); It builds and I can install on the platform. But when I try to launch the app, it gets stuck in an eternal wait state.

I am not sure, but I suspect my locally built app tries to initialize a hardware component on the board and then gets blocked there.

I've been reading articles all over, and seems like it has something to do with the app signing and certificate. I think the general idea is the app needs to be signed with the same certificate with the system itself. I thought, since I built both the app and the system on the same machine using same commands, they would have a same certificate.

If it helps, the manifest file has this line:

android:sharedUserId="android.uid.system"

And the project make file Android.mk has this line:

LOCAL_CERTIFICATE := platform

Can anyone show me how can I make the app work? I am not sure, seems like I have to rebuild the app with proper certificates so that it can access all the hardware resources.

Thanks.

回答1:

Check signing system apk.

Optionally:

You need to create a keystore file by using keytool-importkeypair which you can find here.

Go into the: build/target/product/security/ directory in your platform source tree (source codes related to your Android version and vendor).

You will find platform.pk8 and platform.x509.pem files.

Create keystore file by using this example command:

keytool-importkeypair -k ~/.android/debug.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform

You can use this keystore file to sign your apk which will have system permissions afterwards.