TransWikia.com

frida - The specified child already has a parent. You must call removeView() on the child's parent first when hooking, how do you solve it?

Reverse Engineering Asked by hanan on December 28, 2020

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?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP