找不到符号方法findAndHookMethod(String,ClassLoader,String,<anonymous xc_methodhook =“”>)

时间:2017-03-27 00:27:42

标签: android android-studio xposed

我现在很困惑。除了方法findAndHookMethod()之外,Android Studio正在识别Xposed API库中的所有内容。

这是我的代码:

package com.tylerr147.xposed.red.clock;

import android.graphics.Color;
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.LoadPackageParam;

public class XposedHook implements IXposedHookLoadPackage {
    public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
        if (!lpparam.packageName.equals("com.android.systemui"))
            return;

        findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                TextView tv = (TextView) param.thisObject;
                String text = tv.getText().toString();
                tv.setText(text + " :)");
                tv.setTextColor(Color.RED);
            }
        });
    }
}

唯一的错误是方法findAndHookMethod(),Android Studio没有在Xposed API库中找到它。

我的build.gradle在这里:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.tylerr147.xposed.red.clock"
        minSdkVersion 23
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:24.2.1'
    provided 'de.robv.android.xposed:api:82'
    provided 'de.robv.android.xposed:api:82:sources'
}

以下是Android Studio的屏幕截图,其中包含错误: Image of error

我刚刚开始开发Xposed Modules(这个应用程序实际上是rovo89的红色时钟教程),所以如果这是一个愚蠢的错误,请原谅我。

非常感谢任何帮助。如果您需要更多信息,您需要做的就是询问!

1 个答案:

答案 0 :(得分:1)

你在教程中遗漏了这一行:

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

我的猜测是你的IDE意外删除了它。或者,您只需将findAndHookMethod更改为XposedHelpers.findAndHookMethod

即可