gpt4 book ai didi

java - 配置混淆器以排除扩展 android.content.Context 的库 jar

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:19 25 4
gpt4 key购买 nike

我正在将一个库集成到一个项目的设备中,该项目将被嵌入到设备操作系统中。为此,我们正在集成一个覆盖 Android 框架上下文的库 jar。

因此,尝试为应用程序启用 Proguard 时出现以下错误 - “有 220 个库类实例,具体取决于程序类”。

所有这些文件都是小部件和 View 。我该如何解决这个问题?

这是我的proguard-project.txt的内容

-injars      bin/classes
-outjars bin/classes-processed.jar
-libraryjars /Users/me/android-sdk-mac_86/platforms/android-15/android.jar
-libraryjars libs/library-that-overrides-context.jar

-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.content.Context

这是我的proguard-android.txt的内容

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

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

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

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**

最佳答案

Android Ant/Eclipse 构建会自动为您指定所有必要的 -injars/-outjars/-libraryjars 选项。如果您有自定义构建过程,您应该只指定这些选项。否则,您会收到很多关于重复类和其他可能问题的警告。

如果您确实需要指定 -injars/-outjars/-libraryjars 选项,则使用 -injars 指定的类可以依赖于使用 -libraryjars 指定的类,但反之则不然。 CFR。 ProGuard 手册 > 故障排除 > Warning: library class ... depends on program class ...

关于java - 配置混淆器以排除扩展 android.content.Context 的库 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16215106/

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