Android12上新增jar遇到的问题总结

最近在vendor目录下新增jar遇到一个问题,新增jar完全没问题,但是如果在framework/base/service下通过static_lib调用,就会出现如下报错,在SystemUI中调用都不会出现此问题,这个问题应该就是出现在framework/base/service这个目录下调用才导致的。

error: frameworks/base/services/Android.bp:82:1: module "services" variant "android_common": non-optimal order of jars on the system server classpath: 'services' precedes its dependency 'xxx', so dexpreopt is unable to resolve any references from 'services' to 'xxx'.

我尝试了好几种方法

  1. 将我这个jar目录移动到framework/base/service下,也是同样的报错,且我未修改我的任何代码。

  2. 在framework/base/service下创建目录,将我的jar移动到这下面,参考其他bp的写法,如下所示,就可以编译成功了。

复制代码
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

filegroup {
    name: "services.searchui-sources",
    srcs: ["java/**/*.java"],
    path: "java",
    visibility: ["//frameworks/base/services"],
}

java_library_static {
    name: "services.searchui",
    defaults: ["platform_service_defaults"],
    srcs: [":services.searchui-sources"],
    libs: ["services.core"],
}

2的结果就是不会有单独的jar生成到out下的system/framework下,只会有中间编译产物的jar生成,但由于这个也满足我的需求,就用这个方式了。

算是曲线救国了吧😂

相关推荐
应用市场1 小时前
PHP microtime()函数精度问题深度解析与解决方案
android·开发语言·php
沐怡旸3 小时前
【Android】Dalvik 对比 ART
android·面试
消失的旧时光-19433 小时前
Android NDK 完全学习指南:从入门到精通
android
消失的旧时光-19434 小时前
Kotlin 协程实践:深入理解 SupervisorJob、CoroutineScope、Dispatcher 与取消机制
android·开发语言·kotlin
2501_915921434 小时前
iOS 26 描述文件管理与开发环境配置 多工具协作的实战指南
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_915909064 小时前
iOS 抓包实战 从原理到复现、定位与真机取证全流程
android·ios·小程序·https·uni-app·iphone·webview
2501_915106324 小时前
HBuilder 上架 iOS 应用全流程指南:从云打包到开心上架(Appuploader)上传的跨平台发布实践
android·ios·小程序·https·uni-app·iphone·webview
Meteors.5 小时前
安卓进阶——Material Design库
android·安卓
佳哥的技术分享5 小时前
kotlin基于MVVM架构构建项目
android·开发语言·kotlin
折翅鵬5 小时前
Flutter兼容性问题:Could not get unknown property ‘flutter‘ for extension ‘android‘
android·flutter