Android system integration third-party apk

The list of files required for project integration needs to be copied to the ANDROID_SOURCE/packages/app/PROJECT_NAME/ directory :

PROJECT_NAME
    │ Android.mk
    │ AndroidManifest.xml
    ├─libs[if jar package, static library or dynamic library is included]
    ├─res
    └─src

 

src, res, AndroidManifest.xml are all common applications that will contain content ( don't put the source code in the gen folder under the project, an error will be reported) . The following mainly explains Android.mk. Go directly to the mk content:

 

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := testMid
LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)

 

 

 

1. External jar package dependencies

LOCAL_STATIC_JAVA_LIBRARIES := mirror androidsupport

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := mirror:libs/mirrorcastandroid4.jar androidsupport:libs/android-support-v4.jar

LOCAL_MODULE_TAGS := optional
include $(BUILD_MULTI_PREBUILT)

 

2. Dependency on dynamic library

LOCAL_PREBUILT_LIBS :=libjpeg-turbo:libs/armeabi/libjpeg-turbo.so liblinkyuv:libs/armeabi/liblinkyuv.so

 

Pay attention to the value of the parameter LOCAL_MODULE_TAGS := optional above. When optional, the corresponding .so will not be output to system/lib when making directly . Of course, there are also user, debuguser and other style values), which will output

 

There will be differences between compiling the eng [ie debug] version and the user [ie release] version, and you may encounter the following errors

Error one:

 

build/core/base_rules.mk:64: *** Module name: libjpeg-turbo
build/core/base_rules.mk:65: *** Makefile location: packages/apps/*****/Android.mk
build/core/base_rules.mk:66: *
build/core/base_rules.mk:67: * Module is attempting to use the 'user' tag.  This
build/core/base_rules.mk:68: * used to cause the module to be installed automatically.
build/core/base_rules.mk:69: * Now, the module must be listed in the PRODUCT_PACKAGES
build/core/base_rules.mk:70: * section of a product makefile to have it installed.
build/core/base_rules.mk:71: *
build/core/base_rules.mk:72: *** user tag detected on module..  Stop.
 

 

As detailed in the log output, the system dependency library needs to be declared in PRODUCT_PACKAGES, that is, the build/target/product/generic_*.mk file needs to be modified [generic_no_telephony.mk]

# my product apps
PRODUCT_PACKAGES += \
    libktuart \
    libBT \
    libOUT\
    libUpdate \    
    libjpeg-turbo

 

Error two:

Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlSerializer
Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Note: there were 5 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
Note: there were 2 class casts of dynamically created class instances.
      You might consider explicitly keeping the mentioned classes and/or
      their implementations (using '-keep').
Note: there were 2 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
Warning: there were 78 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
Error: Please correct the above warnings first.
make: *** [out/target/common/obj/APPS/******_intermediates/proguard.classes.jar] Error 1
make: Leaving directory `/home/android'

 

Error two solved:

The above error occurs because all applications will be obfuscated and compiled by default when compiling the release version, and the warning information contained in some files is not allowed. You can configure obfuscation, first modify Android.mk, you can choose to turn off the obfuscation of the current app by the system, or customize the obfuscation configuration file proguard-project.txt

#LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PROGUARD_FLAG_FILES := proguard-project.txt

 

content of proguard-project.txt file

1. Ignore the warning. If the Android source code is added to the project project, and there are modifications, as follows

-dontwarn android.hardware.usb.**

2. Departmental java classes do not need to be obfuscated. For example, some methods are native jni methods, or some methods are called for the C layer, no need to confuse:

-keep class com.test.TestNative{*;}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327058466&siteId=291194637