- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我很难让我的客户的应用程序在启用混淆器的情况下进行编译(我在正确的文件夹中安装了最新版本的混淆器)。 --edit--:我没有使用最新版本,因为安装了多个副本并且构建脚本没有使用正确的版本。
我创建了一个 proguard.cfg解决大部分编译错误的文件。该应用程序针对最新的 android SDK (8) 并将 minSdk 设置为 21。
还有2个编译错误:
#1>PROGUARD : warning : com.google.android.gms.internal.zzx: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzx$zza
#1>PROGUARD : warning : com.google.android.gms.internal.zzx$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzx$zza
在 stackoverflow 上,在 java 上,他们通过向 Graddle 添加一些东西来解决问题。在 Xamarin 上……你不能。
通过在 proguard 文件中添加一条 dontwarn 指令,我能够忽略这 2 条警告。然后它编译、部署和运行几乎正常。几乎所有应用程序都运行良好。
除了:
- Google 身份验证,崩溃
- facebook 身份验证,崩溃
- Google 位置( fuse )崩溃。
崩溃是由缺少方法引起的。 proguard 已删除的方法。
对于 Facebook :
NoSuchMethodError: no non-static method"Lcom/facebook/internal/CallbackManagerImpl;.onActivityResult(IILandroid/content/Intent;)Z"
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <e3048811891c45499b4d89daf4d10667>:0
at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <48117e3895d549baa70c8cbd8592b31c>:0
at Android.Runtime.JNIEnv.GetMethodID (System.IntPtr kls, System.String name, System.String signature) [0x00007] in <758a804725c84b16bcab28b784c87cae>:0
at Xamarin.Facebook.ICallbackManagerInvoker.OnActivityResult (System.Int32 requestCode, System.Int32 resultCode, Android.Content.Intent data) [0x00015] in <53b39e4821ad43cba06dc6bebd7ae5f1>:0
at Appname.Droid.Views.Signup.SignInActivity.OnActivityResult
对于谷歌验证:
NoSuchMethodError: no non-static method "Lcom/google/android/gms/auth/api/signin/internal/zzc;.silentSignIn(Lcom/google/android/gms/common/api/GoogleApiClient;)Lcom/google/android/gms/common/api/OptionalPendingResult;"
对于谷歌位置( fuse ):
NoSuchMethodError: no non-static method "Lcom/google/android/gms/internal/zzary;.requestLocationUpdates(Lcom/google/android/gms/common/api/GoogleApiClient;Lcom/google/android/gms/location/LocationRequest;Lcom/google/android/gms/location/LocationListener;Landroid/os/Looper;)Lcom/google/android/gms/common/api/PendingResult;"
我也尝试过使用 google play 服务的预览 nugets。没有运气。知道如何解决这些错误吗?
** 编辑 1 **使用评论中来自 John Douglas 的链接,以及来自 eugen 的答案中的链接,以及详细的诊断构建,在修复错误 2 小时后,proguard 文件终于可以在 Facebook 和 Google SDK 上正常工作了!
太多了!
最佳答案
这是来自 Android 4.23 的 Facebook SDK 的混淆器配置:
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
来源:facebook-android-sdk on Github
这是来自 Google Play 服务 11.2 的混淆器配置:
# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
# Needed for Parcelable/SafeParcelable classes & their creators to not get renamed, as they are
# found via reflection.
-keep class com.google.android.gms.common.internal.ReflectedParcelable
-keepnames class * implements com.google.android.gms.common.internal.ReflectedParcelable
-keepclassmembers class * implements android.os.Parcelable {
public static final *** CREATOR;
}
# Keep the classes/members we need for client functionality.
-keep @interface android.support.annotation.Keep
-keep @android.support.annotation.Keep class *
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
# Keep the names of classes/members we need for client functionality.
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
# Keep Dynamite API entry points
-keep @interface com.google.android.gms.common.util.DynamiteApi
-keep @com.google.android.gms.common.util.DynamiteApi public class * {
public <fields>;
public <methods>;
}
# Needed when building against pre-Marshmallow SDK.
-dontwarn android.security.NetworkSecurityPolicy
# Needed when building against Marshmallow SDK.
-dontwarn android.app.Notification
# Protobuf has references not on the Android boot classpath
-dontwarn sun.misc.Unsafe
-dontwarn libcore.io.Memory
# Internal Google annotations for generating Proguard keep rules.
-dontwarn com.google.android.apps.common.proguard.UsedBy*
来源:com.google.android.gms:play-services-basement:11.2.0
来自 Google 存储库的 Artifact
Google Play 服务的 Proguard 设置也在 Set Up Google Play Services 中描述。 > 将 Google Play 服务添加到您的项目 > 其他。该配置看起来与库 .aar 中的有所不同,请先尝试这个。
关于android - Proguard 和 Google SDK/Facebook SDK 缺少方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46084657/
https://www.guardsquare.com/en/proguard/manual/optimizations说 class/unboxing/enum Simplifies enum ty
我想使用 ProGuard 重命名变量和函数。我希望生成的类文件在所有方面都与源 jar 相同,除了名称。有没有办法做到这一点? 我尝试使用 dontoptimize 和 dontshrink 无效。
例如,这条规则在 proguard 中意味着什么: -keep class myjava.** {*;} 我理解 {*;} 部分意味着类中的所有成员和方法。但是包名中的 2 个星号是什么意思? 提前致
我有一个即将使用 ProGuard 混淆的库。 “图书馆模式”几乎适用于我的用例,即保留所有公共(public)和 protected 类和类成员几乎没问题。 然而,由于 Java 的可见性要求,一些
在我的 Playstore 中,我注意到去混淆后的代码包含相当多的 在堆栈跟踪中。 (例如 at .onAttach(ProfileLandingFragment.java) )。 有什么用真正意思?
我收到了一封来自 Google 的关于 unsafe implementation of TrustManager 的电子邮件唯一的线索是有问题的代码在 com.b.a.af 类中。显然,这是混淆的名
我读自 http://proguard.sourceforge.net/manual/usage.html关于assumenosideeffects的使用。我的问题涉及以下段落: -assumenos
什么是智能 ProGuard 配置来混淆特定类 com.acme.Algorithm 的私有(private)方法和常量? 我想对此进行混淆,因为它包含一个算法,当意外打开 .jar 时,该算法不应该
最近将 Pushwoosh 库集成到我的 Android 应用程序中。它运作良好。但是在导出为签名应用程序时遇到以下错误。请帮忙。提前致谢。 Proguard returned with error
有没有人有使用ProGuard的经验是否已经有超出类加载时间的应用程序性能测量? 我有一个相当复杂的应用程序,可能需要改进,但为 ProGuard 准备它需要几天时间,所以我想先听听一些意见。 最佳答
当我尝试使用 android studio 3.2 canary 17 构建应用程序包时,我收到以下错误消息。我不知道我所有的 proguard 文件中缺少什么角括号,一切似乎都很好,并且在旧版本的
我遇到了 proguard 的问题,我刚刚配置了 Bugsense 并且使用了它们的配置建议,我在 google 和 stackoverflow 上进行了搜索,通常 ppl 可以在控制台中看到该行或问
我第一次尝试使用 Proguard,我收到此错误,有人可以帮我吗?谢谢 [2014-09-03 11:44:58 - P - Photos] Proguard returned with error
当我收到此错误时,我正在尝试导出启用了 proguard 的 android 应用程序:- Proguard returned with error code 1. See console pro
看起来有两个用于运行 ProGuard 的 SBT 插件。任何人都可以谈谈他们的相对优势和劣势吗?我还没有在网上找到比较。 xsbt-proguard-plugin - https://github.
Proguard 会条纹 kotlin.Unit 独立对象(在 Kotlin 运行时库中),如果您使用此类型,则会导致编译错误。以下规则无助于保留此元素(可能是因为 Unit 不是一个类,它是一个对象
构建 Android 发行版 apk 时,Smack 4.1 的正确 ProGuard 规则是什么? 目前,我正在使用 aSmack github 存储库上 README.asmack 文件中的 aS
尝试使用 Proguard Maven 插件时出现 OutOfMemoryErrors。我尝试通过将 MAVEN_OPTS 环境变量设置为 -Xmx2g 来为 Maven 分配更多内存,但这没有任何区
我有一个 pom.xml 文件如下。当我运行 mvn clean install 时,出现错误 [proguard] Error: Can't read [C:\Program Files\Java\
我已经将支持库从 v22.2.1 更新到 v23.0.0,在构建应用程序后(使用 minifyEnabled true)我有“AppCompat 不支持当前主题功能”异常: 08-23 05:46:1
我是一名优秀的程序员,十分优秀!