Android java.lang.NoSuchMethodError: No virtual method ;or its super classes (declaration of

2023-05-16

修改 AOSP 源码后调用错误 java.lang.NoSuchMethodError: No virtual method *** in class *** ;or its super classes (declaration of ‘***’ appears in /system/framework/framework.jar!classes3.dex)

在 Android 10 AOSP 中自定了新的系统服务,在 app 中调用发现 java.lang.NoSuchMethodError: No virtual method 错误,详情如下:

2022-03-30 15:53:40.678 2046-2046/com.test.tempserviceclient E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.test.tempserviceclient, PID: 2046
    java.lang.NoSuchMethodError: No virtual method getValue()I in class Lcom/test/customservice/TestServiceManager; or its super classes (declaration of 'com.test.customservice.TestServiceManager' appears in /system/framework/framework.jar!classes3.dex)
        at com.test.tempserviceclient.MainActivity.onCreate(MainActivity.java:17)
        at android.app.Activity.performCreate(Activity.java:7853)
        at android.app.Activity.performCreate(Activity.java:7842)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

经过各种搜索 ,查到两种解决方案

  1. 临时设置为可以调用 adb shell settings put global hidden_api_policy 1
  2. 编辑 greylist,将需要设置的包名加入 greylist 中。在 frameworks/base/config/hiddenapi-greylist-packages.txt 中最后一行增加
***
org.apache.xpath
org.apache.xpath.axes
org.apache.xpath.compiler
org.apache.xpath.domapi
org.apache.xpath.functions
org.apache.xpath.jaxp
org.apache.xpath.objects
org.apache.xpath.operations
org.apache.xpath.patterns
org.apache.xpath.res
org.ccil.cowan.tagsoup
org.ccil.cowan.tagsoup.jaxp
+ com.test.customservice

原因是由于在 Android 10 中,针对非 SDK 接口进行了限制,默认是 blacklist 的,通过下面一个命令可以生成包含所有非 SDK 接口及其对应的名单

  • m out/soong/hiddenapi/hiddenapi-flags.csv

然后通过 vim out/soong/hiddenapi/hiddenapi-flags.csv打开改文件,发现 TestServiceManager 为 blacklist , 修复该问题,就用上述方案 (2)

Lcom/test/customservice/ITestService$Default;-><init>()V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Default;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Default;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Default;->getValue()I,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Default;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Default;->setValue(I)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V,blacklist
Lcom/test/customservice/ITestService$Stub$Proxy;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub$Proxy;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String;,blacklist
Lcom/test/customservice/ITestService$Stub$Proxy;->getValue()I,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub$Proxy;->mRemote:Landroid/os/IBinder;,blacklist
Lcom/test/customservice/ITestService$Stub$Proxy;->sDefaultImpl:Lcom/test/customservice/ITestService;,blacklist
Lcom/test/customservice/ITestService$Stub$Proxy;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub$Proxy;->setValue(I)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;-><init>()V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;->DESCRIPTOR:Ljava/lang/String;,blacklist
Lcom/test/customservice/ITestService$Stub;->TRANSACTION_getBundle:I,blacklist
Lcom/test/customservice/ITestService$Stub;->TRANSACTION_getValue:I,blacklist
Lcom/test/customservice/ITestService$Stub;->TRANSACTION_setBundle:I,blacklist
Lcom/test/customservice/ITestService$Stub;->TRANSACTION_setValue:I,blacklist
Lcom/test/customservice/ITestService$Stub;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/test/customservice/ITestService;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;->getDefaultImpl()Lcom/test/customservice/ITestService;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;->getDefaultTransactionName(I)Ljava/lang/String;,blacklist
Lcom/test/customservice/ITestService$Stub;->getTransactionName(I)Ljava/lang/String;,blacklist
Lcom/test/customservice/ITestService$Stub;->onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService$Stub;->setDefaultImpl(Lcom/test/customservice/ITestService;)Z,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService;->getValue()I,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/ITestService;->setValue(I)V,public-api,system-api,test-api,whitelist
Lcom/test/customservice/TestServiceManager;-><init>(Landroid/content/Context;Lcom/test/customservice/ITestService;)V,blacklist
Lcom/test/customservice/TestServiceManager;->TAG:Ljava/lang/String;,blacklist
Lcom/test/customservice/TestServiceManager;->getBundle()Landroid/os/Bundle;,blacklist
Lcom/test/customservice/TestServiceManager;->getValue()I,blacklist
Lcom/test/customservice/TestServiceManager;->iTestService:Lcom/test/customservice/ITestService;,blacklist
Lcom/test/customservice/TestServiceManager;->setBundle(Landroid/os/Bundle;)V,blacklist
Lcom/test/customservice/TestServiceManager;->setValue(I)V,blacklist

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android java.lang.NoSuchMethodError: No virtual method ;or its super classes (declaration of 的相关文章

  • 按下后退按钮时停止 Fragments 中的 AsyncTask

    我有一个托管片段的活动 按下按钮会通过 FragmentTransaction 从片段 A 转到片段 B 并将其添加到返回堆栈中 现在片段 B 有一个 AsyncTask 实现 它从 sdcard 加载图像并在加载图像时将其发布 如果我按
  • 将 LinkedHashset 内容复制到新的 ArrayList?

    我有一个最初包含一些内容的 listView 如果它得到相同的内容 我通过删除重复linkedhashset 现在 我想复制linkedhashset内容 即没有重复的内容到新的ArrayList 我尝试复制通过 p addAll 0 lh
  • 更新(合并)时缺少 Spring Data JPA 验证

    我正在使用 Spring Boot 1 5 4 RELEASE 和 Spring Data JPA 进行项目 遇到更新实体时未执行 Hibernate 验证器或至少在某些情况下未验证的问题 For Person如下所示 禁止使用空名称 并且
  • 如何在javafx中通过事件传递参数?

    我有以下示例 我想将参数 文本 与事件一起传递 当单击按钮 bla 时 我该怎么做 EventHandler
  • 安装我的应用程序时的 android 意图

    安装我的应用程序时我需要执行一项操作 我研究过使用 Intent PACKAGE ADDED 但我没有收到正在安装的应用程序中的意图 我想在第一次安装我的应用程序时运行代码 该用例是注册在线服务 我可以列出 BOOT COMPLETED 如
  • 从 MySql 迁移:MariaDB 服务器意外关闭客户端连接

    由于许可 商业使用原因 我们正在从 MySql 迁移到 MariaDB 我们已经成功用 MariaDB 客户端 jar 替换了 MySql 连接器 jar 第一次更改 现在正在尝试用 MariaDB 服务器替换 MySql 服务器而不更改数
  • 如何将 HTML 转换为保留换行符的文本

    我如何将 HTML 转换为保留换行符的文本 由 br p div 等元素生成 可能使用NekoHTML http nekohtml sourceforge net 或任何足够好的 HTML 解析器 Example Hello br Worl
  • 使用 JSeperator - Java 时出现异常间隙

    我一直在开发 Swing GUI 并在添加后出现一些不寻常和不需要的间隙JSeperator 知道如何删除它们吗 或者任何其他选择来很好地实现这一目标 视觉描述 之前差距就很明显了JLabel 速度 及之后JSlider 相关代码 cont
  • android:configChanges 清单文件中不允许错误字符串类型

    这是我的清单文件 其中显示 android configChanges 不允许的错误字符串类型 请帮助我纠正错误 下面是我的清单文件
  • 消费者关闭了输入通道或发生错误。事件=0x8

    D AndroidRuntime 11752 D AndroidRuntime 11752 gt gt gt gt gt gt AndroidRuntime START com android internal os RuntimeInit
  • BLE:使用 Android / iOS 读取长特征值

    对于正常的特征读取 仅读取 MTU 大小 20 字节 的数据 我的客户将提供更大尺寸 超过 100 字节 的特征 我看到 BLE 提供了 长读取 功能 可以读取直到达到特征的大小 https bluegiga zendesk com ent
  • 如何:获取 AVD 的端口号并向其自身发送消息

    我该如何执行以下操作 获取我的 AVD 的端口号 从我的代码而不是命令行 使用步骤 1 中获得的端口号从 AVD 向自身发送消息 这是可能的 模拟器可以给自己发送短信吗 https stackoverflow com questions 8
  • Android:从 Android Java 源代码创建 UML [已关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在寻找一个可以从我的 Java Android 源代码自动创建 Uml 的程序 我测试过ArgoU
  • Android 上页面留在后台时会触发“beforeunload”事件

    我正在尝试制作一个在导航时弹出的简单加载微调器 它在导航离开时使用 beforeunload 事件显示 并在完成后使用 load 事件再次隐藏自身 问题是 当我将页面留在手机后台时 例如几个小时后 beforeunload 事件触发并显示微
  • 如何使用放心发送Content-Type表单数据请求?

    我需要使用 Rest Assured 调用表单数据类型 API 这是我的代码 private Map
  • 三角形未在 OSX 上的 OpenGL 2.1 中绘制

    我正在学习有关使用 OpenGL 在 Java 中创建游戏引擎的教程 我正在尝试在屏幕上渲染一个三角形 一切运行良好 我可以更改背景颜色 但三角形不会显示 我还尝试运行作为教程系列的一部分提供的代码 但它仍然不起作用 教程链接 http b
  • Java 中的引用变量里面有什么?

    我们知道对象引用变量保存表示访问对象的方式的位 它不保存对象本身 但保存诸如指针或地址之类的东西 我正在阅读 Head First Java 第 2 版 一书 书中写道 第 3 章第 54 页 在 Java 中我们并不真正知道什么是 在引用
  • 返回数据集的 kSoap 和 .Net Web 服务

    我知道使用数据集是一个很大的罪恶 但由于该服务不在我的控制之下 并且创建代理服务的前景是不可能的 我想看看是否有人创建了可以使用 kSoap 序列化器反序列化的类结构 或者我是否吸错了东西 同时要启动它 看看是否可行 以下是预期的结果数据
  • 如何以编程方式滚动 Horizo​​ntalScrollView

    我有一个HorizontalScrollView其中包含一个RelativeLayout 该布局在 XML 中为空 并由 onCreate 中的 java 填充 我希望这个滚动视图最初位于中间的某个位置RelativeLayout 它比屏幕
  • Robotium 和系统对话框

    当我尝试与蓝牙设备配对时 会出现带有 PIN 码的系统确认对话框 有 取消 和 确定 按钮 但我无法使用 Robotium 单击它们 如何在 Robotium 中使用 Android 操作系统对话框 谢谢 这对我有用 solo clickO

随机推荐

  • 史上最全的字符串格式化方法,学这些就够用了

    一 思考 1 什么是字符串格式化 将变量 xff08 对象 xff09 的值填充到字符串中 在字符串中解析Python表达式 对字符串进行格式化显示 左对齐 右对齐 居中对齐保留数字有效位数 2 你学过的字符串格式化方式有哪些 字符串格式化
  • Linux实现黑客帝国效果,超级简单

    MATRIX是Linux的环境下黑客帝国风格的屏保 xff0c 绿色的字母在屏幕上刷刷如雨水落下 xff0c 偶尔看看能回忆起程序猿的黑客梦 首先要在网上找到CMATRIX安装包 xff0c 然后安装 xff0c 需要的话找柠檬班小米 xf
  • 10年互联网职场过来人给测试专业大学生的学习建议

    改进学习方法 xff0c 就如改进你的测试方法一样 不管你面临的是什么环境和挑战 xff0c 值得期许的 就值得去尝试 1 关于学习 在学校期间以专业课为主 xff0c 专业理论知识越扎实 xff0c 后期实践才越容易深入理解且上手更快 对
  • 使用 GitHub Copilot 自动化测试

    代码完成并不是什么新鲜事 像 IntelliSense 这样的工具已经允许开发人员通过尝试自动完成他们正在编写的函数或语句的名称来提高工作效率 xff0c 但是可用的工具只有一定程度的实际 智能 可用 随着 GitHub 的 Copilot
  • 想让你的接口自动化测试更加有效? 这个统计方法必须掌握

    覆盖率概念 接口自动化测试是现代软件开发中不可或缺的一环 xff0c 它能够帮助开发团队自动化执行测试用例 xff0c 以快速而准确地发现并修复软件缺陷 而覆盖率统计则是在测试执行完成后 xff0c 帮助测试团队了解哪些代码路径被覆盖了 x
  • 大小端字节序详解

    目录 引文 大小端介绍 xff08 1 xff09 什么是大端小端 xff08 2 xff09 为什么有大端和小端 xff08 3 xff09 笔试题讲解 引文 在开始正文之前 xff0c 我想先问一下大家 xff0c 内存中是怎样存放一个
  • 【C库函数】strcat函数详解

    目录 strcat 函数原型 参数讲解 返回值详解 函数讲解 xff08 1 xff09 源字符串和目标字符串都必须以 39 0 39 结束 xff08 2 xff09 目标空间必须足够大 xff0c 能容纳下源字符串的内容 xff08 3
  • CAN协议

    CAN xff08 Controller Area Network xff09 是一种常见的串行总线通信协议 xff0c 用于在汽车 工业控制和其他应用中传输数据 它是一种高效 可靠 安全的通信协议 xff0c 具有广泛的应用 下面是CAN
  • 串口协议简介

    串口协议是一种基于串行通信的数据传输协议 它通过串口接口将数据以串行的方式传输 串口协议通常包括物理层 数据链路层和应用层三个部分 xff0c 其中物理层主要定义了串口接口的电气特性 xff0c 数据链路层定义了数据的传输方式和错误检测机制
  • CAN协议总线仲裁原理:数据发送权争夺

    CAN总线仲裁原理是指在多个CAN节点同时发送数据时 xff0c 如何避免冲突 并选择一个节点作为发送者 CAN总线的仲裁原理基于一个分布式仲裁机制 xff0c 它可以快速而可靠地确定哪个节点可以获得总线控制权 xff0c 从而发送数据 C
  • Spring整合JMS(一)——基于ActiveMQ实现

    1 1 JMS简介 JMS的全称是Java Message Service xff0c 即Java消息服务 它主要用于在生产者和消费者之间进行消息传递 xff0c 生产者负责产生消息 xff0c 而消费者负责接收消息 把它应用到实际的业务需
  • getopt函数详解

    getopt 函数是C语言中一个常用的命令行参数解析函数 xff0c 它可以方便地解析命令行输入的参数 xff0c 以便程序对不同参数进行不同的处理 本文将详细讲解getopt 函数的使用方法和注意事项 xff0c 分点阐述如下 xff1a
  • UCOSIII

    UCOSIII简介 xff1a UCOSIII是MicroC OS III的改编版本 xff0c 主要是用于实时系统中的任务调度 xff0c 它是嵌入式系统中应用最广泛的操作系统之一 用函数说明 xff1a 1 OSInit 用于初始化UC
  • UCOSIII-任务创建-库函数

    创建任务 xff1a OSTaskCreate OS TCB amp StartTaskTCB 任务控制块 xff08 amp 传地址 xff09 CPU CHAR 34 start task 34 任务名字 xff08 可以随便写 xff
  • ucosiii-常用api

    uC OS III 提供了许多 API 函数 xff0c 可以根据需要选择使用 以下是一些常用的 uC OS III API 函数 xff1a 任务管理 API OSTaskCreate xff1a 创建一个新任务 xff1b OSTask
  • windows 清除 .git 文件夹

    有时我们需要将 git 管理项目中的 git文件夹删除 xff0c 但是如果项目太多 xff0c 一个一个手动删除太麻烦 xff0c 这时候可以用 bat 批处理文件删除 xff0c 具体操作如下 桌面 右击 新建文本文档 xff0c 此时
  • Your anti-virus program might be impacting your build performance.解决方案

    Your anti virus program might be impacting your build performance 解决方案 在使用 AndroidStudio 时 xff0c 经常会弹出框提示 xff1a Your ant
  • init.rc 启动 shell 脚本 开机执行脚本 init.rc执行shell脚本

    Android 重启时执行 shell 脚本 init rc 执行 shell 脚本 最近有个需求 xff0c 需要生成系统的默认配置 xff0c 使得在系统开机后 xff0c 直接读取已经配置好的文件 当时想的解决方案是 xff0c 在编
  • android 10 自定义系统服务接口给app调用

    Android 安卓自定义系统服务 最近有个需求 xff0c 要增加系统服务 xff0c 生成第三方 jar 包提供给第三方应用调用 xff0c 而且 jar 包必须用特定的包名 xff0c 最后生成的 jar 包不能包含 framewor
  • Android java.lang.NoSuchMethodError: No virtual method ;or its super classes (declaration of

    修改 AOSP 源码后调用错误 java lang NoSuchMethodError No virtual method in class or its super classes declaration of appears in sy