本章开始测试生成的apk文件,看是否能正常跑起来,已经坚持了那么久,是不是非常期待!
使用Android Studio调试系统应用之TvSettings(一):移植
使用Android Studio调试系统应用之TvSettings(二):build.gradle
使用Android Studio调试系统应用之TvSettings(三):首次编译
使用Android Studio调试系统应用之TvSettings(四):SettingsLib module 移植
使用Android Studio调试系统应用之TvSettings(五):再次编译,生成APK文件
platform代表系统签名,相关内容可以百度一下。从下面AOSP源码目录的搜索情况看,有多个文件,该使用哪一个呢?
AOSP使用的是./build/make/target/product/security/platform.x509.pem;但测试后发现APK无法成功安装。该如何解决呢?
其实很个直接了当的方法,从开发板的/system/app目录下复制一个系统应用,然后使用jadx-gui等反编译工具,查看一下它的签名是多少,然后用下面的签名文件,逐个试一次,找到SHA-256值相同的密钥即可。
szhou@server_01:~/works/aosp_tv$ find . -name platform.x509.pem
./vendor/google_mt5862/security/platform.x509.pem
./vendor/google_mediatek/security/platform.x509.pem
./vendor/google_m7642/security/platform.x509.pem
./vendor/google_m7332/security/platform.x509.pem
./vendor/mediatek/proprietary_tv/open/product/m7632/security/platform.x509.pem
./vendor/mediatek/proprietary_tv/open/common/security/platform.x509.pem
./build/make/target/product/security/platform.x509.pem
./build/make/tools/releasetools/testdata/platform.x509.pem
szhou@server_01:~/works/aosp_tv$
从系统上拉取了同名TvSettingsPlus.apk,查看其SHA-256签名,如上图,值为:FE 96 开头,最后确认到开发板的签名文件为
./vendor/mediatek/proprietary_tv/open/common/security/platform.x509.pem
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$java -jar -Djava.library.path="/home/builder/code/3m/out/host/linux-x86/lib64/" /home/builder/code/3m/out/host/linux-x86/framework/signapk.jar platform.x509.pem platform.pk8 app-debug.apk sign-app-debug.apk
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$adb connect 192.168.103.237
connected to 192.168.103.237:5555
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$adb install sign-app-debug.apk
Success
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$adb shell am start -n com.android.tv.settings/com.android.tv.settings.MainSettings
Starting: Intent {
cmp=com.android.tv.settings/.MainSettings }
通过查看app/AndroidManifest.xml文件,就选用“.MainSettings”主菜单来做最后的验收测试。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tv.settings"
android:sharedUserId="android.uid.system"
android:versionCode="1"
android:versionName="1.0" >
<activity
android:name=".MainSettings"
android:excludeFromRecents="true"
android:theme="@style/Theme.Settings.Transparent"
android:configChanges="keyboard|keyboardHidden|navigation"
android:label="@string/settings_app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
intent-filter>
$adb connect 192.168.103.237
connected to 192.168.103.237:5555
$adb install sign-app-debug.apk
Success
$adb shell am start -n com.android.tv.settings/com.android.tv.settings.MainSettings
Starting: Intent {
cmp=com.android.tv.settings/.MainSettings }
使用screencap命令截个图,然后再来回本地。
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$adb shell screencap /data/TvSettingPlus_MainActivity.png
builder@mm-mh(trunk_for_coding):~/code/3m/vendor/mediatek/proprietary_tv/open/common/security$adb pull /data/ TvSettingPlus_MainActivity.png .
这个错误是因为未找到引用类的实现,体现为本应该为STATIC打包的类,被写成了CompileOnly
例如:
implementation files('../libs/mtk-support-sharecode.jar')
错误写成了:
ompileOnly files('../libs/mtk-support-sharecode.jar')
其中一种情况,如下所示,把本该compileOnly 的JAR,作为了STATIC打包进了APK中
例如:
compileOnly files('../libs/mtk-framework.jar')
错误写成了
implementation files('../libs/mtk-framework.jar')
花了不少时间,终于把一个实验的各个步骤完整的记录下来了,但系列文章,尚未结束,挺累,也挺开心:)