gpt4 book ai didi

android - Proguard 和 Scoreloop

转载 作者:太空狗 更新时间:2023-10-29 16:43:16 25 4
gpt4 key购买 nike

我正在尝试在我的 Android 项目上使用 Proguard,但在 Scoreloop(3.0.3 版)库的运行时不断出现相同的错误...

我在 project.properties 文件中定义了 proguard 配置文件:

proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
proguard.enabled=true

这是我的 proguard-project.txt 文件(包含所有内容,以防我在某处做错了……):

# ####### #
# Project #
# ####### #
-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


# ##### #
# AdMob #
# ##### #
-keep public class com.google.ads.** {*;}
-keep public class com.google.gson.** {*;}


# #### #
# ACRA #
# #### #
# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this...
-keepattributes *Annotation*

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {*;}

# keep this around for some enums and classes that ACRA needs
-keep class org.acra.ReportingInteractionMode {*;}
#-keep class org.acra.ReportField {*;}
-keepnames class org.acra.ReportField {*;}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter {
public void addCustomData(java.lang.String,java.lang.String);
}
-keep public class org.acra.ErrorReporter {
public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
}


# ######### #
# Scoreloop #
# ######### #
-dontwarn com.scoreloop.client.android.core.paymentprovider.**
-keep class com.scoreloop.client.android.core.paymentprovider.fortumo.FortumoPaymentProviderController {*;}
-keep class com.scoreloop.client.android.core.paymentprovider.fortumo.FortumoPaymentProvider {*;}
-keep class com.scoreloop.client.android.core.paymentprovider.paypalx.PayPalXPaymentProviderController {*;}
-dontwarn com.scoreloop.client.android.core.ui.WebViewDialog
-keep class com.scoreloop.client.android.core.ui.WebViewDialog {*;}
-keep class com.facebook.android.** {*;}


# ############## #
# In-App Billing #
# ############## #
# -keep class com.android.vending.billing.**


# ####### #
# OrmLite #
# ####### #
# OrmLite uses reflection
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }

我在运行时遇到这个错误:

Caused by: java.lang.IllegalArgumentException: java.lang.NoSuchMethodException: <init> [class com.scoreloop.client.android.core.b.aw]
at com.scoreloop.client.android.core.b.j.a(SourceFile:692)
at com.scoreloop.client.android.core.b.j.<init>(SourceFile:368)
at com.sofresh.games.megaflux.MegaFluxApplication.onCreate(SourceFile:106)
at com.sofresh.games.megaflux.MegaFluxApplication_.onCreate(SourceFile:19)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
... 10 more
Caused by: java.lang.NoSuchMethodException: <init> [class com.scoreloop.client.android.core.b.aw]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getConstructor(Class.java:431)
at com.scoreloop.client.android.core.b.j.a(SourceFile:684)

从文件 mapping.txt 中,我发现了有关有问题的类和调用的信息:

com.scoreloop.client.android.core.model.Client -> com.scoreloop.client.android.core.b.j:
java.util.Map a -> a
com.scoreloop.client.android.core.model.ClientObserver b -> b
com.scoreloop.client.android.core.model.Session c -> c
103:104:boolean a(java.util.Properties,java.lang.String,boolean) -> a
155:178:java.util.Properties a(android.content.Context) -> a
182:185:void a(java.util.Properties,java.lang.String) -> a
188:194:void a(java.util.Properties,java.lang.String,java.lang.String) -> a
198:232:void a(android.content.Context,java.lang.String) -> a
380:387:void a(java.util.Properties) -> a
638:640:int b(java.util.Properties,java.lang.String) -> b
684:692:void a(java.lang.Class) -> a
708:711:void a$2a1b557e(com.scoreloop.client.android.core.model.Session) -> a
715:718:boolean a(com.scoreloop.client.android.core.model.Session) -> b
722:723:void b(android.content.Context) -> b
[...]
com.scoreloop.client.android.core.model.Session -> com.scoreloop.client.android.core.b.aw:
[...]

所以我认为错误是说它找不到接受Session的Client的构造函数。我尝试将以下内容添加到我的 proguard conf 中:

-keep class com.scoreloop.client.android.core.model.** {*;}
-keepclassmembers class com.scoreloop.client.android.core.model.**

运气不好,现在我收到了这个错误:

Caused by: java.lang.IllegalArgumentException: java.lang.NoSuchMethodException: <init> [class com.scoreloop.client.android.core.model.Session]
at com.scoreloop.client.android.core.model.Client.a(SourceFile:692)
at com.scoreloop.client.android.core.model.Client.a(SourceFile:605)
at com.scoreloop.client.android.core.model.Client.<init>(SourceFile:368)
at com.blabla.MyApplication.onCreate(SourceFile:106)
at com.blabla.MyApplication_.onCreate(SourceFile:19)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
... 10 more
Caused by: java.lang.NoSuchMethodException: <init> [class com.scoreloop.client.android.core.model.Session]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getConstructor(Class.java:431)
at com.scoreloop.client.android.core.model.Client.a(SourceFile:684)

现在我对接下来要尝试的事情有点迷茫......关于这个错误的任何想法和启示?

最佳答案

在得到 Scoreloop 支持的响应和我这边的一些测试后,这里是 Scoreloop 的 ProGuard 配置:

# ######### #
# Scoreloop #
# ######### #
-dontwarn com.scoreloop.client.android.core.paymentprovider.**
-keep class com.scoreloop.client.android.core.paymentprovider.fortumo.FortumoPaymentProviderController {*;}
-keep class com.scoreloop.client.android.core.paymentprovider.fortumo.FortumoPaymentProvider {*;}
-keep class com.scoreloop.client.android.core.paymentprovider.paypalx.PayPalXPaymentProviderController {*;}
-dontwarn com.scoreloop.client.android.core.ui.WebViewDialog
-keep class com.scoreloop.client.android.core.ui.WebViewDialog {*;}
-keep class com.facebook.android.** {*;}
-keep class com.scoreloop.client.android.core.** { *; }

关于android - Proguard 和 Scoreloop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14344100/

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