IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 游戏开发 -> Android java.lang.NoSuchMethodError: No virtual method ;or its super classes (declaration of -> 正文阅读

[游戏开发]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 /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

  游戏开发 最新文章
6、英飞凌-AURIX-TC3XX: PWM实验之使用 GT
泛型自动装箱
CubeMax添加Rtthread操作系统 组件STM32F10
python多线程编程:如何优雅地关闭线程
数据类型隐式转换导致的阻塞
WebAPi实现多文件上传,并附带参数
from origin ‘null‘ has been blocked by
UE4 蓝图调用C++函数(附带项目工程)
Unity学习笔记(一)结构体的简单理解与应用
【Memory As a Programming Concept in C a
上一篇文章      下一篇文章      查看所有文章
加:2022-04-01 23:44:41  更:2022-04-01 23:47:40 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年1日历 -2025/1/30 7:08:51-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码