Android 开发中,Android Studio中默认调用使用sdk中接口,但部分系统应用需要优先使用自己Android编译后的framework_classes.jar。
下面简单记录一下,方便自己查阅。
PS:亲测有效,但出处忘记了,抱歉,感谢大哥分享。
正文
下面是的配置,以BiuSystemUI为例
libs
BiuSystemUI/libs
创建libs目录,放入framework_classes.jar
build.gradle
BiuSystemUI/build.gradle
中添加
dependencies { compileOnly files('libs/framework_classes.jar') //略 }
最后面继续添加
// 优先链接framework_classes.jar gradle.projectsEvaluated { // 方法一 // tasks.withType(JavaCompile) { // Set<File> fileSet = options.bootstrapClasspath.getFiles(); // List<File> newFileList = new ArrayList<>() // newFileList.add(new File("libs/framework_classes.jar")) // newFileList.addAll(fileSet) // options.bootstrapClasspath = files(newFileList.toArray()) // } // 方法二 tasks.withType(JavaCompile).tap { configureEach { options.compilerArgs.add("-Xbootclasspath/p:$rootProject.rootDir/BiuSystemUI/libs/framework_classes.jar") } } }
上面2中方式都可以,我试过。
![[摘]对于Fragment的一些理解](https://www.biumall.com/wp-content/themes/BiuX/assets/images/random/0.webp)