xpose框架使用android studio

写一个测试项目

package com.ijingyir.lier.testb;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private Button btChange;
    private TextView tvText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btChange = (Button) findViewById(R.id.bt_change);
        tvText = (TextView) findViewById(R.id.tv_text);
        btChange.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                tvText.setText("天平");
            }
        });
    }
}

建立无界面工程

main目录libs加入
api-82.jar
main目录新建assets目录在新建xposed_init文件
com.example.administrator.xposedtest.HookMain(填写入口文件)

添加provided files(‘libs/api-82.jar’)
provided 提供包但不会编译进程序,如果一下有一个是compile 把 api-82编译进去了,程序就会出现无法进入自定义handleLoadPackage的情况

dependencies {
    provided fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    testCompile 'junit:junit:4.12'
    provided files('libs/api-82.jar')
}

java下写Main

package com.example.administrator.testxposed;


import android.widget.TextView;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

/**
 * Created by Administrator on 2018/3/1.
 */

public class Main implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable{

        XposedBridge.log("handleLoadPackage执行了");
        if(loadPackageParam.packageName.equals("com.ijingyir.lier.testb")){
            XposedBridge.log("开始hook测试程序!");

            findAndHookMethod(TextView.class,"setText",CharSequence.class,
                    new XC_MethodHook(){

                        protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
                            XposedBridge.log("处理setText方法前");

                            param.args[0] = "我是被Xposed修改的";
                        }

                        protected void afterHookMethod(MethodHookParam param) throws Throwable{
                            XposedBridge.log("处理setText方法后");
                        }
                    }
            );
        }
    }
}

这里写图片描述

xpose框架使用android studio_第1张图片

还有file->setting里面有个 instanrun的选项要取消掉

你可能感兴趣的:(android脱壳)