java - 将变量添加到 framework.jar 后,它仍然无法访问
问题描述
我正在尝试通过添加静态布尔变量(仅用于测试)来修改 frameworks.jar。为此,我从模拟器中提取了 frameworks.jar,将其反编译并添加到 LocationManager 中:
.field public static TEST:Z = 0x0
为了测试这个变量,我创建了一个小应用程序,我试图使用这行代码访问这个变量
sget-boolean v1, Landroid/location/LocationManager;->TEST:Z
但这给了我一个例外。我检查了修改的framework.jar 是否通过拉取和反编译来替换原来的。我在我从手机中提取的 framework.jar 中找到了这个变量。如果这个变量存在,为什么它仍然告诉我它不存在
例外
06-30 02:16:53.388 E/AndroidRuntime(10801): FATAL EXCEPTION: main
06-30 02:16:53.388 E/AndroidRuntime(10801): Process: com.greedycat.smalitest, PID: 10801
06-30 02:16:53.388 E/AndroidRuntime(10801): java.lang.IllegalStateException: Could not execute method for android:onClick
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.view.View.performClick(View.java:6302)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.view.View$PerformClick.run(View.java:24782)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.os.Handler.handleCallback(Handler.java:790)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.os.Looper.loop(Looper.java:164)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.app.ActivityThread.main(ActivityThread.java:6518)
06-30 02:16:53.388 E/AndroidRuntime(10801): at java.lang.reflect.Method.invoke(Native Method)
06-30 02:16:53.388 E/AndroidRuntime(10801): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
06-30 02:16:53.388 E/AndroidRuntime(10801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
06-30 02:16:53.388 E/AndroidRuntime(10801): Caused by: java.lang.reflect.InvocationTargetException
06-30 02:16:53.388 E/AndroidRuntime(10801): at java.lang.reflect.Method.invoke(Native Method)
06-30 02:16:53.388 E/AndroidRuntime(10801): at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
06-30 02:16:53.388 E/AndroidRuntime(10801): ... 9 more
06-30 02:16:53.388 E/AndroidRuntime(10801): Caused by: java.lang.NoSuchFieldError: No static field TEST of type Z in class Landroid/location/LocationManager; or its superclasses (declaration of 'android.location.LocationManager' appears in /system/framework/framework.jar)
06-30 02:16:53.388 E/AndroidRuntime(10801): at com.greedycat.smalitest.MainActivity.click(MainActivity.java:20)
06-30 02:16:53.388 E/AndroidRuntime(10801): ... 11 more
06-30 02:16:53.392 W/ActivityManager( 1237): Force finishing activity com.greedycat.smalitest/.MainActivity
解决方案
变量名称是 TEST,异常提到 IS_MOCKING 所以你没有正确重新编译应用程序或类似的东西。
推荐阅读
- python - 使用 glLoadMatrix 和 glm.value_ptr() 时出错
- c++ - 将右值引用传递给类构造函数有什么意义?
- javascript - 当我在 Google 课堂脚本中的“AddStudentIds”键之后列出 ID 时,如何更正“无效的解构分配目标”
- python - 收到结果后python测试继续运行
- web-scraping - 如何设置scrapy spider在多个页面上运行 - 没有下一页按钮
- go - 如何将 gomega 的 ContainElements 匹配器与自定义相等匹配器一起使用
- c# - 在 .net core 3.1 中,如何从不记名令牌返回数据?
- python - 为什么 Python 对象在父进程和子进程之间具有相同的地址?
- php - fontawesome 不显示 laravel 项目中的图标
- java - 手机号码验证需要指导