Billdesk Android SDK

时间:2017-03-15 14:00:25

标签: android sdk android-proguard

我将ProGuard应用于 Billdesk SDK 时遇到问题。

如果我在没有ProGuard的情况下构建apk,那么工作正常,但如果使用ProGuard进行构建,则会出现错误,

  

SDK未正确初始化。

我的应用程序的当前ProGuard规则如下,

# code for optimazation
-dontnote org.json.**
-dontwarn org.apache.http.**
-dontnote org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontnote android.net.http.**

#OKHTTP
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

-dontwarn okio.**


# Retrofit 2.X
## https://square.github.io/retrofit/ ##

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

# Simple-Xml Proguard Config
# NOTE: You should also include the Android Proguard config found with the build tools:
# $ANDROID_HOME/tools/proguard/proguard-android.txt

# Keep public classes and methods.
-dontwarn com.bea.xml.stream.**

-dontwarn org.simpleframework.xml.stream.**
-dontwarn javax.xml.**

-keep public class org.simpleframework.**{ *; }
-keep class org.simpleframework.xml.**{ *; }
-keep class org.simpleframework.xml.core.**{ *; }
-keep class org.simpleframework.xml.util.**{ *; }

-keepattributes Signature
-keepattributes *Annotation*

# Ignore our XML Serialization classes
-keep public class packagename.model.ServerResponse{
  public protected private *;
}
-keep public class packagename.model.ServerRequest{
  public protected private *;
}

-keep public class packagename.activity.ProceedToPayActivity{
  public protected private *;
}



-keep public class packagename.model.ServerResponseHeader{
  public protected private *;
}


#
#-dontwarn com.bea.xml.stream.**
#
#-keep class org.simpleframework.xml.**{ *; }
#-keepclassmembers,allowobfuscation class * {
#    @org.simpleframework.xml.* <fields>;
#    @org.simpleframework.xml.* <init>(...);
#}



-keep class com.jamesmurty.** { *; }
-dontwarn com.jamesmurty.utils.**

##
##Billdesk rules
-keep public class com.billdesk.sdk.*
-keep public class com.billdesk.config.*
-keep public class com.billdesk.utils.URLUtilActivity
-keep public interface com.billdesk.sdk.LibraryPaymentStatusProtocol{
public void paymentStatus(java.lang.String,android.app.Activity);
}
-keep class com.billdesk.sdk.PaymentWebView$JavaScriptInterface{
public void gotMsg(java.lang.String);
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keep public class com.billdesk.sdk.PaymentWebView$JavaScriptInterface
-keep public class * implements com.billdesk.sdk.PaymentWebView$JavaScriptInterface
-keepclassmembers class com.billdesk.sdk.PaymentWebView$JavaScriptInterface {
<methods>;
}

1 个答案:

答案 0 :(得分:0)

对于Billdesk使用电话,

BilldeskPaymentCallback billdeskPaymentCallback = new BilldeskPaymentCallback();
Intent intent = new Intent(getApplicationContext(), PaymentOptions.class);
intent.putExtra(Constants.BILLDESK_MESSAGE, billdeskToken); //pg_msg
intent.putExtra(Constants.BILLDESK_CALLBACK, billdeskPaymentCallback);
startActivity(intent);
  

它将访问您的输入并为其创建JSON。

错误是我没有为JSON编写proguard规则,

添加此代码后,工作正常。

-keep public class org.json.*{ *; }
-keep class org.json.*{ *; }
-keepclassmembers,allowobfuscation class * {
    @org.json.* <fields>;
    @org.json.* <init>(...);
}