Abstract

In the Internet of Things project (control version is Android system), the two interfaces IPackageInstallObserver and IPackageDeleteObserver are used to achieve silent upgrade. Because these two interface systems hide the API externally; So it can not be used, the board manufacturers need to compile framework.jar in the system source code;


1. Copy framework.jar to the Libs folder in the Androidstudio project directory. Right click, select Add As Library, and then select the module where Framework. jar is located to automatically introduce framework.jar to build.gradle of the Module

   

// Dependencies closure compileOnly files('libs/framework.jar') in modele build.gradleCopy the code

Change implementation to compileOnly so that framework.jar is used only at compiletime and apK packages are not packaged.

Provided Implementation Files ('libs/framework.jar') //compileOnly provided Implementation Files ('libs/framework.jar')Copy the code

3. Add it in the AllProjects closure of project build.gradle

Gradle.projectsevaluated {tasks.withType(JavaCompile) {// note: Options.pilerargs. Add (' -xbootclasspath /p:app\ libbs \framework.jar') }}Copy the code

Error handling:

After the above configuration is complete, make project compiles the project if the following error occurs:

Solutions:

Implementation fileTree(include: [‘*.jar’], dir: ‘libs’);

apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.installpackagedemo" MinSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName testInstrumentationRunner "1.0" "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), //implementation fileTree(include: ['*.jar'], implementation fileTree(include: ['*.jar']) 'libs') implementation' com. Android. Support: appcompat - v7:28.0.0 'implementation 'com. Android. Support. The constraint, the constraint - layout: 1.1.3' testImplementation junit: junit: '4.12' androidTestImplementation 'com. Android. Support. Test: runner: 1.0.2' androidTestImplementation 'com. Android. Support. Test. Espresso: espresso - core: 3.0.2' compileOnly files (' libs/framework. The jar ')}Copy the code