我尝试混淆我的项目,以便在 Gradle 中启用一些设置。然后我尝试反转代码但不完全混淆
我参考了很多网站我还没有找到一个确切的解决方案
我尝试反编译非常著名的应用程序,例如来自 Play 商店的任何 google 应用程序和 Facebook(代码似乎完全被混淆了)。
任何人都可以建议我应该做什么来使完整的代码混淆
- 以下 3 个步骤 代码混淆没有用处
第 1 步: Gradle 属性:
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=obsolete
android.enableR8.fullMode=true
第 2 步:应用级 Gradle:
buildTypes {
release {
useProguard true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
第 3 步: proguard-rules.pro 我也尝试了 proguard 规则
# If you keep the line number information, uncomment this to
# hide the original source file name.
-renamesourcefileattribute SourceFile
这是我的科特林代码:
package com.android.myapplication
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Log.d("myTag","on create")
try{
val deviceInfo = " MOBILE: Android" +
" APP VERSION:" + BuildConfig.VERSION_NAME +
" MODEL:" + Build.MODEL +
" Manufacture:" + Build.MANUFACTURER +
" BRAND:" + Build.BRAND +
" SDK:" + Build.VERSION.SDK +
" OS: " + Build.VERSION.RELEASE
//Sets the text to be displayed.
android_info.text =deviceInfo
} catch (e: Exception){
android_info.text =e.message
}
}
}
在这里,我尝试反转我的发布版本的代码。 Android Apk 反编译器: http ://www.javadecompilers.com/apk
反编译器输出:
package com.android.myapplication;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.util.HashMap;
import p000a.p002b.p003c.C0034n;
import p082c.p083a.p084a.C0741a;
public final class MainActivity extends C0034n {
/* renamed from: o */
public HashMap f2788o;
/* renamed from: o */
public View mo2896o(int i) {
if (this.f2788o == null) {
this.f2788o = new HashMap();
}
View view = (View) this.f2788o.get(Integer.valueOf(i));
if (view != null) {
return view;
}
View findViewById = findViewById(i);
this.f2788o.put(Integer.valueOf(i), findViewById);
return findViewById;
}
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView((int) R.layout.activity_main);
Log.d("myTag", "on create");
try {
TextView textView = (TextView) mo2896o(R.id.android_info);
C0741a.m1859a(textView, "android_info");
textView.setText(" MOBILE: Android APP VERSION:1.0 MODEL:" + Build.MODEL + " Manufacture:" + Build.MANUFACTURER + " BRAND:" + Build.BRAND + " SDK:" + Build.VERSION.SDK + " OS: " + Build.VERSION.RELEASE);
} catch (Exception e) {
TextView textView2 = (TextView) mo2896o(R.id.android_info);
C0741a.m1859a(textView2, "android_info");
textView2.setText(e.getMessage());
}
}
}
注意: 启用上述 Gradle 设置后:
- 应用程序大小减少 40%
- 它还删除了我项目中未使用的类和 res 文件。