Giter Club home page Giter Club logo

Comments (13)

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

应该是字节码兼容问题, 你用的moshi 库 是哪个版本的

from lancetx.

Alexxiaopang avatar Alexxiaopang commented on May 14, 2024

应该是字节码兼容问题, 你用的moshi 库 是哪个版本的

1.14.0和1.13.0都试了,都不行,冲突了么?

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

这应该是 byteX 默认的ASM版本的问题,

你可以通过 byteX的配置 来支持, 通过修改根工程目录的 gradle.properties ,增加以下配置。
bytex.ASM_API=ASM8
bytex.enableDuplicateClassCheck=false

或者把moshi的库过滤掉。

配置用法详见
https://github.com/bytedance/ByteX/blob/90979d010d5af56e44566a12b827f1f46a38bd4f/wiki/ByteX-Developer-API-zh.md

from lancetx.

Alexxiaopang avatar Alexxiaopang commented on May 14, 2024

这应该是 byteX 默认的ASM版本的问题,

你可以通过 byteX的配置 来支持, 通过修改根工程目录的 gradle.properties ,增加以下配置。 bytex.ASM_API=ASM8 bytex.enableDuplicateClassCheck=false

或者把moshi的库过滤掉。

配置用法详见 https://github.com/bytedance/ByteX/blob/90979d010d5af56e44566a12b827f1f46a38bd4f/wiki/ByteX-Developer-API-zh.md

非常感谢,已经可以运行了,但是加了ASM之后,编译时间由之前的一分钟变成了五分钟,这个编译是真的慢啊

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

如果你之前项目没有ASM,现在加了ASM 确实对编译时间有较大影响, 不过第二次编译会快一点。

from lancetx.

Alexxiaopang avatar Alexxiaopang commented on May 14, 2024

关于功能性的可以问一下么?我想拦截Calendar.getInstance()按照语法按照以下书写,但是怎么样都没有日志输出,也没拦截成功

@weaver
public class CalendarProxy {

@Proxy()
@TargetClass(value = "android.util.Calendar", scope = Scope.ALL)
@TargetMethod(methodName = "getInstance")
public static Calendar replaceGetInstance() {
    Calendar calendar = (Calendar) Origin.call();
    calendar.setFirstDayOfWeek(Calendar.SUNDAY);
    Log.e("拦截了can", "calendar getFirstDayOfWeek" + calendar.getFirstDayOfWeek());
    return calendar;
}

}

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

这是一个静态函数吗?

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

这种系统的类,没法直接修改 原类字节码的,我建议直接用 @RepalceInvoke

可以参考:https://github.com/Knight-ZXW/LancetX/blob/main/app/src/main/java/com/knightboost/lancetx/weaver/ReplaceInvokeTest.java

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024
@ReplaceInvoke(isStatic = true)
@TargetClass(value = "android.util.Log",scope = Scope.SELF)
@TargetMethod(methodName = "i")
public static int replaceLogI2(String tag,String msg){
    msg = msg + "被替换";
    return Log.e("zxw",msg);
}

from lancetx.

Alexxiaopang avatar Alexxiaopang commented on May 14, 2024
@ReplaceInvoke(isStatic = true)
@TargetClass(value = "android.util.Log",scope = Scope.SELF)
@TargetMethod(methodName = "i")
public static int replaceLogI2(String tag,String msg){
    msg = msg + "被替换";
    return Log.e("zxw",msg);
}

log我拦截都是可以的,只是Calendar 不生效,可能是因为这个类是 抽象的原因,我再看看吧

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024
@ReplaceInvoke(isStatic = true)
@TargetClass(value = "java.util.Calendar",scope = Scope.SELF)
public static Calendar getInstance(){
    Calendar instance = Calendar.getInstance();
     Log.e("CalendarWeave","calender getInstance hook");
     return null;
}

修改前

image

修改后
image

image

目前这个插件不支持增量编译, 你可以clean下工程后 重新试试

from lancetx.

frankswu avatar frankswu commented on May 14, 2024

这应该是 byteX 默认的ASM版本的问题,

你可以通过 byteX的配置 来支持, 通过修改根工程目录的 gradle.properties ,增加以下配置。 bytex.ASM_API=ASM8 bytex.enableDuplicateClassCheck=false

或者把moshi的库过滤掉。

配置用法详见 https://github.com/bytedance/ByteX/blob/90979d010d5af56e44566a12b827f1f46a38bd4f/wiki/ByteX-Developer-API-zh.md

请问 “把moshi的库过滤掉” 是指把依赖中的moshi过滤掉?

from lancetx.

Knight-ZXW avatar Knight-ZXW commented on May 14, 2024

这应该是 byteX 默认的ASM版本的问题,
你可以通过 byteX的配置 来支持, 通过修改根工程目录的 gradle.properties ,增加以下配置。 bytex.ASM_API=ASM8 bytex.enableDuplicateClassCheck=false
或者把moshi的库过滤掉。
配置用法详见 https://github.com/bytedance/ByteX/blob/90979d010d5af56e44566a12b827f1f46a38bd4f/wiki/ByteX-Developer-API-zh.md

请问 “把moshi的库过滤掉” 是指把依赖中的moshi过滤掉?

bytex.globalIgnoreClassList 参数可以过滤处理的类,具体看bytex文档

from lancetx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.