admin管理员组

文章数量:1123409

I obfuscated my Java files, however when opening the files with Android's Java Decompiler, It fully exposed the supposedly obfuscated code.

I want to obfuscate my Java files properly.

code snippet of one my classes as you can see the obfuscation is being applied

    public static final String Q = "Main";
    public static boolean R;
    public static boolean S;
    public static int T;
    public static LinearLayout U;
    public static LinearLayout V;
    public static final String W = "com.android.example.USB_PERMISSION";
    public static final int X = 516;
    public static final int Y = 515;
    public static final int Z = 514;
    public g a;
    public UsbManager b;

the same snippet but exposed using Android's Java Decompiler

private static final String TAG = "Main";
    protected static boolean log_dbg = true;
    protected static boolean loc_srv = true;
    protected static int urlConn = 0;
    Variables variables;
    static LinearLayout ll_history_view;
    static LinearLayout ll_reading_view;
    private UsbManager usbManager;
    private UsbDevice deviceFound;
    private UsbDeviceConnection usbDeviceConnection = null;
    private UsbInterface usbInterfaceFound = null;
    private UsbEndpoint endpointOut = null;
    private UsbEndpoint endpointIn = null;
    private PendingIntent UsbPermissionPI;
    private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";

proguard-rules.pro

-keepparameternames
-dontshrink
-dontoptimize

build.gradle

plugins {
    id 'com.android.library'
}

android {
    namespace 'com.example.application'
    compileSdk 34

    defaultConfig {
        minSdk 30
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            consumerProguardFiles 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation libs.core
    implementation 'com.android.support:multidex:1.0.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}

By Android Java Decompiler, I just Control + Left Click the class and It opens and builds the Java file normally

Notice: I'm not sure if It's called Java Decompiler officially, in order to use It for the first time It prompted a message that I had to agree to.

本文标签: ProGuard Obfuscated files are easily decoded using Android Java DecompilerStack Overflow