out_sys\soong\.intermediates\frameworks\base\framework-minus-apex\android_common\combined 获取framework.jar build.gradle中修改 apply plugin: 'com.android.application' android { compileSdkVersion 33 defaultConfig { minSdkVersion 28 targetSdkVersion 33 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } gradle.projectsEvaluated { tasks.withType(JavaCompile) { Set<File> fileSet = options.bootstrapClasspath.getFiles() List<File> newFileList = new ArrayList<>() newFileList.add(new File("libs/framework.jar")) newFileList.addAll(fileSet) options.bootstrapClasspath = files(newFileList.toArray()) } } } repositories { flatDir { dirs 'libs' } } dependencies { //implementation fileTree(dir: 'libs', include: ['*.jar']) compileOnly files("libs/framework.jar") implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') configurations.all { exclude group: 'com.hikrobot.hikdevicemanager', module: 'BuildConfig' } configurations.all { exclude group: 'com.xunmeng.scarecrow.device_api', module: 'BuildConfig' } androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:26.+' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' } gradle.projectsEvaluated { tasks.withType(JavaCompile){ options.compilerArgs << '-Xbootclasspath/p:app/libs/framework.jar' } } preBuild { doLast { // 注意:iml的路径要根据自己的实际情况来写 def imlFile = file("../.idea/modules/app/My_Application.app.main.iml") try { def parsedXml = (new XmlParser()).parse(imlFile) def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } parsedXml.component[1].remove(jdkNode) def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" new groovy.util.Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) } catch (FileNotFoundException e) { } } } preBuild { doLast { def imlFile = file(project.name + ".iml") println 'Change ' + project.name + '.iml order' try { def parsedXml = (new XmlParser()).parse(imlFile) def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } parsedXml.component[1].remove(jdkNode) def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) } catch (FileNotFoundException e) { // nop, iml not found } } }