0

I wanted to hook the method A1f in the below code but frida returns the following exceptions:

Found instance: MyHomeFragment{9bbd8d5} (0965bca9-4838-4ca1-a835-d99639ae15f1)}
java.lang.IllegalStateException: Fragment MyHomeFragment{9bbd8d5} (0965bca9-4838-4ca1-a835-d99639ae15f1)} not attached to an activity.
Found instance: MyHomeFragment{8e4752} (c7e2fb7a-bbcd-4b79-b9ff-ce1a06117e40) id=0x7f0a0e33}
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

how can I call removeView() through frida just to solve that exception? is it possible to do that? additionally is there ways to hook? I am new to frida instrumentation. Here is the method to hook:

public final class MyHomeFragment extends 1Id implements 1Ij, C4Z, 1Io, 2OS {
    public 0ou A00;
    public 65i A01;
    public String A02;

public final View A1f(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        int A022 = 051.A02(1608567253);
        65i r1 = this.A01;
        Preconditions.checkNotNull(r1);
        LithoView A07 = r1.A07(A0w());
        FrameLayout frameLayout = new FrameLayout(A0m());
        frameLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        frameLayout.addView(A07);
        051.A08(-871184214, A022);
        return frameLayout;
    }
}

and the frida script I tried to hook with:

Java.perform(function () {
   Java.choose("com.myapp.perish.home.fragments.MyHomeFragment", {
    onMatch: function (instance) {
      //This function will be called for every instance found by frida
      try {
        var LayoutInflater = Java.use("android.view.LayoutInflater");
        var ViewGroup = Java.use("android.view.ViewGroup");
        var Bundle = Java.use("android.os.Bundle");
     
        console.log("Found instance: " + instance);
        console.log(JSON.stringify(instance.A1f(null, null, null)));
      } catch (e) {
        console.log(e.message);
      }
    },
    onComplete: function () {},
  });
});

previously I tried to pass LayoutInflater ViewGroup Bundle arguments to A1f method I got an exception depicting that .overload method got differently what it expects. I don't how to solve it. but when replaced all the three params with null. I got that above exception that parentView should be removed! how can I solve this?

0

Check if you have any ConstrainLayout (or similar) in your layouts files. As may be the reason for throwing that error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.