Android Question Using 3rd party library with AAR file

Mark Ryan Penafiel

Member
Licensed User
I want to use a 3rd party payment library with aar file.

their documentation is

https://t.2c2p.com/Manuals/android/request_nonui/newpayment.html


the AAR file can be found here

https://2c2p-cloudfront.s3-ap-south...demoCode/Mobile/v3/PGW_SDK_ANDROID_v3.9.0.zip

however by just adding the aar code,

#AdditionalJar:
#AdditionalJar: PGW_SDK_ANDROID_v3.9.0.aar
i have this error


B4A Version: 10.50
Parsing code. (0.01s)
Java Version: 11
Building folders structure. (0.05s)
Compiling code. (0.01s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.00s)
Compiling generated Java code. (0.10s)
Convert byte code - optimized dex. Error
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.String[] using a local variable of type android.os.Parcel. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object[] using a local variable of type com.samsung.android.sdk.samsungpay.SSamsungPay. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.String[] using a local variable of type com.samsung.android.sdk.samsungpay.v2.VersionChecker. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type org.spongycastle.asn1.ASN1OctetString[] using a local variable of type org.spongycastle.asn1.ASN1Sequence. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type byte[] using a local variable of type org.spongycastle.asn1.ASN1OutputStream. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type byte[] using a local variable of type org.spongycastle.asn1.DERObjectIdentifier. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type byte[] using a local variable of type org.spongycastle.asn1.eac.CertificateHolderAuthorization. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type char[] using a local variable of type org.spongycastle.asn1.eac.PackedDate. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type byte[] using a local variable of type org.spongycastle.asn1.eac.UnsignedInteger. This is symptomatic of .class transformation tools that ignore local variable information.
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
at com.android.dx.command.dexer.Main.runDx(Main.java:293)
at com.android.dx.command.dexer.Main.main(Main.java:249)
at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:684)
... 4 more

cant find a similar error, any idea. Ty
 

DonManfred

Expert
Licensed User
The Library must be Desugared. Just adding them is not enough here. Maybe Jetifying it can work (you need to try).
Jetify:
Desugar:

You need to write a wrapper for this AAR to use which requires some java-knowledge.
Alternatively you can use JAvaObject to work with it. requires some java-knowledge too.
 
Upvote 0

drgottjr

Well-Known Member
Licensed User
this may go beyond desugaring. i desugared the .aar and tried to compile the example. none of the errors you reported appeared, BUT a missing resolution of androidx fragment was triggered. when i downloaded that from maven and rebuilt, all the errors you reported came back. some googling indicated that the errors have to do with proguard. when i checked the androidx fragment .aar, it had, in fact, been built with proguard. (your .aar did not use proguard). i don't know what you end up with if you desugar such an .aar. i think this is getting above my pay grade, so i humbly abandon ship at this point. sorry.
 
Last edited:
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
thank you for your response,

in the manual for android studio, it needed to setup a proguard. can be this be also be done in b4a? Thank you

proguard config file:
#Optional for proguard, you may use your own proguard configuration.
    -dontusemixedcaseclassnames
    -dontpreverify
    -optimizationpasses 5
    -keepparameternames
    -renamesourcefileattribute SourceFile

    #Mandatory for PGW SDK
    #2C2P PGW Library
    -dontwarn com.ccpp.my2c2psdk.**
    -keep class com.ccpp.my2c2psdk.** { *; }
    -keep interface com.ccpp.my2c2psdk.** { *; }

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

    #okhttp3
    -dontwarn okio.**
    -keep class okhttp3.** { *; }
    -keep interface okhttp3.** { *; }
    -dontwarn okhttp3.**
    -keepclassmembers class * extends javax.net.ssl.SSLSocketFactory {
        private final javax.net.ssl.SSLSocketFactory delegate;
    }
    -dontwarn javax.annotation.**
    -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
    -dontwarn org.codehaus.mojo.animal_sniffer.*
    -dontwarn okhttp3.internal.platform.ConscryptPlatform

    #Samsung Pay
    -dontwarn com.samsung.**
    -keep class com.samsung.** { *; }

    #Spongy Castle
    -dontwarn org.spongycastle.**
    -keep class org.spongycastle.** { *; }

    #AliPay
    -dontwarn com.alipay.**
    -dontwarn org.json.alipay.**
    -keep class com.alipay.** { *; }
    -keep class org.json.alipay.** { *; }
    -keep class com.alipay.android.app.IAlixPay{*;}
    -keep class com.alipay.android.app.IAlixPay$Stub{*;}
    -keep class com.alipay.android.app.IRemoteServiceCallback{*;}
    -keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
    -keep class com.alipay.sdk.app.PayTask{ public *;}
    -keep class com.alipay.sdk.app.AuthTask{ public *;}
    -keep class com.alipay.sdk.app.H5PayCallback {
        <fields>;
        <methods>;
    }
    -keep class com.alipay.android.phone.mrpc.core.** { *; }
    -keep class com.alipay.apmobilesecuritysdk.** { *; }
    -keep class com.alipay.mobile.framework.service.annotation.** { *; }
    -keep class com.alipay.mobilesecuritysdk.face.** { *; }
    -keep class com.alipay.tscenter.biz.rpc.** { *; }
    -keep class org.json.alipay.** { *; }
    -keep class com.alipay.tscenter.** { *; }
    -keep class com.ta.utdid2.** { *;}
    -keep class com.ut.device.** { *;}
    -dontwarn com.ta.utdid2.**
    -dontwarn com.ut.device.**
    -dontwarn com.alipay.mobilesecuritysdk.**
    -dontwarn com.alipay.security.**
 
Upvote 0
Top