androidandroid-studioxposed

cannot find symbol method findAndHookMethod(String,ClassLoader,String,<anonymous XC_MethodHook>)


I am very confused right now. Android Studio is recognizing everything from the Xposed API library, except the method findAndHookMethod().

This is my code:

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);
            }
        });
    }
}

The only error is the method findAndHookMethod(), Android Studio is not finding it in the Xposed API library.

My build.gradle is here:

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'
}

Here is a screenshot of Android Studio with the error: Image of error

I am just getting started with developing Xposed Modules (This app is literally rovo89's Red Clock tutorial), so if this is some stupid mistake, please pardon me.

Any help is extremely appreciated. If you need any more information all you need to do is ask!


Solution

  • You're missing this line from the tutorial:

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

    My guess is that your IDE removed it by accident. Alternatively, you can just change your use of findAndHookMethod to XposedHelpers.findAndHookMethod.