【问题标题】:Generate a obfuscated JAR for code distribution为代码分发生成一个混淆的 JAR
【发布时间】:2013-12-19 02:02:53
【问题描述】:

我正在开发一个 Android 库项目。我想将此库作为 JAR 分发给其他开发人员。在分发 JAR 之前,我想对其进行混淆。我曾尝试为此目的使用 PROGUARD,但它在最后一步失败并说

The output jar is empty. Did you specify the proper '-keep' options?

谁能指出出了什么问题?

=================编辑:错误日志=======================

ProGuard, version 4.7
Reading program jar [C:\Users\XYZ\Downloads\login.jar]
Reading library jar [D:\Softwares\Android SDK\adt-bundle-windows-x86-20130522\sdk\platforms\android-8\android.jar]
Note: the configuration refers to the unknown class 'javax.swing.plaf.ComponentUI'
Note: the configuration refers to the unknown class 'javax.swing.plaf.ComponentUI'
Note: the configuration refers to the unknown class 'javax.swing.JComponent'
Note: there were 3 references to unknown classes.
You should check your configuration for typos.
The output jar is empty. Did you specify the proper '-keep' options?

=============== 编辑:proguard.cfg =====================

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keep public class MyClass extends MyView {

public static String GetSessionID () {
    }
}

-keepclasseswithmembernames class * {
   native <methods>;
}

-keepclasseswithmembernames class * {
   public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
   public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
   public static **[] values();
   public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
   public static final android.os.Parcelable$Creator *;
}

【问题讨论】:

  • 你能出示你的proguard文件吗?
  • 在您的 proguard 文件中添加 -dontwarn 试试看。
  • 像这样添加-keep class javax.swing.plaf.** { *; } 这应该可以。
  • 您是否尝试在文件中添加-dontwarn 行?
  • 是的。也试过了,但没有成功。

标签: android jar obfuscation


【解决方案1】:

在您的 proguard 文件中添加这一行。

 -keep class <your jar file name>.** { *; }

【讨论】:

  • 试过了。不工作:( ...现在还有一个与我的 JAR 名称同名的类
  • @Mayank 请出示您的 proguard 文件和完整的错误日志。你用的是哪个jar文件?
猜你喜欢
  • 1970-01-01
  • 2019-06-28
  • 2011-11-21
  • 1970-01-01
  • 2017-03-01
  • 2022-10-14
  • 2017-11-24
  • 2023-04-08
  • 2018-07-13
相关资源
最近更新 更多