1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 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

时间:2019-03-04 00:29:53

相关推荐

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 错误,详情如下:

-03-30 15:53:40.678 2046-2046/com.test.tempserviceclient E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.test.tempserviceclient, PID: 2046java.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:)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)

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

临时设置为可以调用adb shell settings put global hidden_api_policy 1编辑 greylist,将需要设置的包名加入 greylist 中。在frameworks/base/config/hiddenapi-greylist-packages.txt中最后一行增加

***org.apache.xpathorg.apache.xpath.axesorg.pilerorg.apache.xpath.domapiorg.apache.xpath.functionsorg.apache.xpath.jaxporg.apache.xpath.objectsorg.apache.xpath.operationsorg.apache.xpath.patternsorg.apache.il.il.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,whitelistLcom/test/customservice/ITestService$Default;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Default;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Default;->getValue()I,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Default;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Default;->setValue(I)V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V,blacklistLcom/test/customservice/ITestService$Stub$Proxy;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub$Proxy;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String;,blacklistLcom/test/customservice/ITestService$Stub$Proxy;->getValue()I,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub$Proxy;->mRemote:Landroid/os/IBinder;,blacklistLcom/test/customservice/ITestService$Stub$Proxy;->sDefaultImpl:Lcom/test/customservice/ITestService;,blacklistLcom/test/customservice/ITestService$Stub$Proxy;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub$Proxy;->setValue(I)V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;-><init>()V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;->DESCRIPTOR:Ljava/lang/String;,blacklistLcom/test/customservice/ITestService$Stub;->TRANSACTION_getBundle:I,blacklistLcom/test/customservice/ITestService$Stub;->TRANSACTION_getValue:I,blacklistLcom/test/customservice/ITestService$Stub;->TRANSACTION_setBundle:I,blacklistLcom/test/customservice/ITestService$Stub;->TRANSACTION_setValue:I,blacklistLcom/test/customservice/ITestService$Stub;->asBinder()Landroid/os/IBinder;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/test/customservice/ITestService;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;->getDefaultImpl()Lcom/test/customservice/ITestService;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;->getDefaultTransactionName(I)Ljava/lang/String;,blacklistLcom/test/customservice/ITestService$Stub;->getTransactionName(I)Ljava/lang/String;,blacklistLcom/test/customservice/ITestService$Stub;->onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService$Stub;->setDefaultImpl(Lcom/test/customservice/ITestService;)Z,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService;->getBundle()Landroid/os/Bundle;,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService;->getValue()I,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService;->setBundle(Landroid/os/Bundle;)V,public-api,system-api,test-api,whitelistLcom/test/customservice/ITestService;->setValue(I)V,public-api,system-api,test-api,whitelistLcom/test/customservice/TestServiceManager;-><init>(Landroid/content/Context;Lcom/test/customservice/ITestService;)V,blacklistLcom/test/customservice/TestServiceManager;->TAG:Ljava/lang/String;,blacklistLcom/test/customservice/TestServiceManager;->getBundle()Landroid/os/Bundle;,blacklistLcom/test/customservice/TestServiceManager;->getValue()I,blacklistLcom/test/customservice/TestServiceManager;->iTestService:Lcom/test/customservice/ITestService;,blacklistLcom/test/customservice/TestServiceManager;->setBundle(Landroid/os/Bundle;)V,blacklistLcom/test/customservice/TestServiceManager;->setValue(I)V,blacklist

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。