如何防止逐渐混淆更改代码?

发布于 2025-01-31 09:41:32 字数 534 浏览 2 评论 0原文

我对proguard混淆有问题,它更改了代码的某些部分并导致错误 例如,我有以下代码:

for (int i=0;i <rowsNb; i++){
    try {
        Integer.parseInt (model.getValueAt(i,0));
    catch (Exception){
        continue;
    }
    doSomething();
}

混淆之后,代码的此部分变为这样:

for (int i=0;i <rowsNb; i++){
    try {
        model.getValueAt(i,0);
    catch (Exception){}
    doSomething();
}

它删除Integer.parseint()方法,我用来检查第一列是否是一个整数,这是执行dosothing()的条件,而无需错误

而且我在班级名称上还有另一个问题,有些课程仍然有其原始名称(在混淆之前的名称),

谢谢

I have a problem with proguard obfuscation it changes some parts of the code and causes errors
for example I have the following code:

for (int i=0;i <rowsNb; i++){
    try {
        Integer.parseInt (model.getValueAt(i,0));
    catch (Exception){
        continue;
    }
    doSomething();
}

after obfuscation this part of code becomes like this:

for (int i=0;i <rowsNb; i++){
    try {
        model.getValueAt(i,0);
    catch (Exception){}
    doSomething();
}

it deletes the integer.parseInt() method that I use to check if the first column is an integer which is a condition to execute doSomething() without errors

and I have another problem with class names, some classes still have their original names (their names before obfuscation)

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪你到最终 2025-02-07 09:41:32
  • 这个问题已经9个月大了,我确实找到了一个解决方案,但是我忘记了在这里发布它,所以我为此表示歉意。
  • proguard的问题在于,它在调用诸如integer.parseint()之类的函数时会弄乱,但不使用其返回值,因此它会消除它并可能导致错误(取决于代码),因此只需使用另一种方式来测试值是整数还是将返回值分配给变量。
  • 对于保留某些类原始名称的另一个问题,我注意到它只保留包含主要方法的类的名称,因此您可以在混淆之前手动将它们重命名。
  • This question is 9 months old now, I did find a solution but I forget to post it here so I apologize for that.
  • The problem with proguard is that it messes up when calling a function like Integer.parseInt() but not using its return value, so it gets rid of it and that can cause errors (depending on the code), so just use another way to test if the values is an integer or assign the return value to a variable.
  • For the other question about keeping some classes original names I noticed that it only keeps the names of the classes that contain a main method, so you can rename them manually just before obfuscation.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文