我正在尝试通过添加静态布尔变量(仅用于测试)来修改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
答案 0 :(得分:0)
变量名称为TEST,例外情况提及IS_MOCKING,因此您没有正确重新编译应用程序或类似的东西。