拆aar,并打包jar为dex
~/Android/Sdk/build-tools/30.0.2/dx --dex --output=classes.dex ./*.jar
jar cf iiot.jar classes.dex
把jar 和 So 放到指定目录,并在device.mk中添加对应的配置
project device/xxx/xxx_x/device.mk
+PRODUCT_COPY_FILES += $(LOCAL_PATH)/libxxxio_linux.so:system/lib/libxxxio_linux.so
+PRODUCT_COPY_FILES += $(LOCAL_PATH)/com.xxx.iot.jar:system/framework/com.xxx.iot.jar
声明library
project frameworks/base/data/etc/platform.xml
<library name="org.apache.http.legacy"
file="/system/framework/org.apache.http.legacy.boiot.jar" />
+
+ <library name="com.xxx.iot"
+ file="/system/framework/com.xxx.iot.jar"/>
声明So
project system/core//roiotdir/etc/public.libraries.android.txt
libc++.so
libandroid_runtime.so
+libxxxio_linux.so
应用层使用:
<application
android:name=".xxxx"
tools:replace="android:label,android:allowBackup">
<uses-library android:name="com.xxx.iot"
android:required="true"/>
添加防混淆
-keep class io.netty.** {*;}
-keep class org.slf4j.** {*;}
-keep class com.xxx.bridge.** {*;}
-keep class com.xxx.xxxio.** {*;}
-keep class com.xxx.xxxiot.** {*;}
-keep class com.xxx.tool.** {*;}
-keep class com.ouyang.** {*;}
添加AAR中的清单文件
<service
android:name="com.xxxx"
android:enabled="true"
android:process=":xxx"
android:exported="false" >
<intent-filter android:priority="1000" >
<action android:name="xxxxx" />
</intent-filter>
</service>