Proguard并没有混淆AAR课程

问题描述 投票:0回答:1

我一直试图告诉proguard为aar文件中使用的任何东西重命名类。

假设我在AAR文件中定义了此文件

package com.myweb.lib.common;

import android.graphics.Color;
import java.util.Random;

public class ColorUtil
{
  public static int randomColor()
  {
    Random localRandom = new Random();
    return Color.argb(255, localRandom.nextInt(256), localRandom.nextInt(256), localRandom.nextInt(256));
  }
}

没有为AAR定义的Proguard文件。

我的proguard规则是为消费者应用程序定义的

-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-flattenpackagehierarchy ''

-keep class com.myweb.lib.networkservices.models.** { *; }
-keep class com.myweb.helpmate.http.** { *; }
-keep class android.location.** { *; }

gradle构建如下:

 buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFile 'proguard-gson.pro'
            proguardFile 'proguard-square-retrofit2.pro'
            proguardFile 'proguard-square-okio.pro'
            proguardFile 'proguard-rules.pro'
            proguardFile 'proguard-support-v7-appcompat.pro'
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
            signingConfig signingConfigs.release
        }
    }

但是,当我反编译时,我可以看到它的类。

我想要实现的是:

  • 更改方法名称
  • 更改班级名称
  • 更改变量名称
  • 也可能更改包裹

因此很难将它的使用方式联系起来。

android gradle proguard android-proguard
1个回答
0
投票

您无法编制已创建的aar文件。您或其他人创建aar文件的库模块需要设置proguard配置,以便它可以在其module-name / build / outputs / aar目录下输出模糊的aar文件。

© www.soinside.com 2019 - 2024. All rights reserved.