我还没有吃饱 2016-06-05 06:42
浏览 3416

Android反射问题, InvocationTargetException

通过反射调用私有无参函数,函数内部:

     private int TargetFunction()
    {
        Log.d("DEBUG","进入了宿主函数TargetFunction");
        Dialog alertDialog = new AlertDialog.Builder(MainActivity.this).
                setTitle("确定删除?").
                setMessage("您确定删除该条信息吗?").
                setIcon(R.mipmap.ic_launcher).
                setPositiveButton("确定", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        myFunction();
                    }
                }).
                setNegativeButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                    }
                }).
                setNeutralButton("查看详情", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                    }
                }).
                create();
        alertDialog.show();
        return 9991;
    }

当调用之后可以成功进入该函数内,但随即抛错,log信息如下:

 进入了宿主函数TargetFunction
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at tools.unicorn.dexinject.MyApplication.abcd(MyApplication.java:55)
    at tools.unicorn.dexinject.MyApplication.dexInject(MyApplication.java:21)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.aninterface.hook.hook_target.MainActivity.loadUninstallApk(MainActivity.java:123)
    at com.aninterface.hook.hook_target.MainActivity.access$100(MainActivity.java:22)
    at com.aninterface.hook.hook_target.MainActivity$2.onClick(MainActivity.java:39)
    at android.view.View.performClick(View.java:4780)
    at android.view.View$PerformClick.run(View.java:19866)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
    at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:149)
    at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:99)
    at android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:154)
    at android.app.AlertDialog$Builder.<init>(AlertDialog.java:379)
    at com.aninterface.hook.hook_target.MainActivity.TargetFunction(MainActivity.java:46)
    ... 19 more

不知有谁遇到过这样的问题,小弟实在是找不到原因了

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题