gpt4 book ai didi

安卓:配置混淆器

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:54:09 26 4
gpt4 key购买 nike

我正在尝试配置混淆器并遇到了一些按优先级排序的问题:

  • 我收到了重复 zip 的警告并且无法修复它。我在“libs”目录中使用外部库和 2 个库项目(一个库项目有一个外部库 - 仅添加到项目一次)仅添加到项目一次。我试图将我的外部 jars 移动到另一个目录,即“lib”——只是重命名,因为一些用户已经设法解决了这个问题,但这对我没有帮助。另一种方法是尝试将 custom_rules 实现到基本的 build.xml,因为它可以帮助一些用户避免这些警告。但是它的一切都对我没有帮助,我该如何解决?日志:

    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jackson-annotations-2.1.4.jar:META-INF/MANIFEST.MF])
    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [android-support-v4.jar:META-INF/MANIFEST.MF])
    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [google-analytics-v2.jar:META-INF/MANIFEST.MF])
    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jackson-core-2.1.4.jar:META-INF/MANIFEST.MF])
    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [httpclientandroidlib-1.1.2.jar:META-INF/MANIFEST.MF])
    ProGuard: Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [deviceprint-lib-1.0.0.jar:META-INF/MANIFEST.MF])
  • 最后一件事是签名 apk 构建过程中的一些注意事项:

    ProGuard: Note: com.google.analytics.tracking.android.AdHitIdGenerator: can't find dynamically referenced class com.google.ads.AdRequest
    ProGuard: Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
    ProGuard: Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'

完整混淆文件:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

# Otherwise return Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
-dontwarn com.fasterxml.jackson.databind.**

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

# Preserve all fundamental application classes.
-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.view.View
-keep public class * extends android.preference.Preference
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

# Preserve ActionBarSherlock and Android support libraries` classes and interfaces
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

# Preserve all Jackson library classes
-keep class com.fasterxml.jackson.** { *; }

# Original
-keepclasseswithmembernames class * {
native <methods>;
}

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

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

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

-keepclassmembers class **.R$* {
public static <fields>;
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

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

#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}

最佳答案

您当前列出的 6 条警告和 3 条注意事项是无害的。

您应该确保您使用的是最新版本的 Android SDK,它会为您的项目创建一个空的 proguard-project.txt。标准的 Ant 构建和 Eclipse 构建在内部负责重要的配置(我假设您使用的是 IDEA 中的 Ant)。您仍然可以将特定于应用程序的选项添加到 proguard-project.txt,例如 Jackson 和 ActionBarSherlock 的 -keep 选项。不要添加诸如 -injars/-libraryjars/-outjars 之类的选项,因为构建过程会为您指定它们。

关于安卓:配置混淆器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16420464/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com