Error when I need generate signed APK

Forum / MIFARE SDK / Error when I need generate signed APK

  • 18. September 2018 at 4:43
    Hi, Im using the last version of the TapLinx lib (1.4.1). The app works well in debug mode but I have problems to generate a signed APK with proguard.

    Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unknown option '-android' in line 4 of file


    The generated proguard.txt with the error is:




    -android




    -keepclassmembers,allowobfuscation class com.nxp.nfclib.if {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.NxpNfcLib {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.analytics.AnalyticsTracker {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.classic.ClassicFactory {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.cloud.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.cloud.TrustIdCloudClient {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.defaultimpl.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.defaultimpl.SecureKeyGenerator {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.?$? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.DESFireFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.DESFireFile {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.EV1ApplicationKeySettings {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.EV1PICCKeySettings {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.EV2ApplicationKeySettings {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.MFPCard {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.MFPDESFireFile {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.MIFAREIdentityUtility {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.icode.ICodeFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.interfaces.CryptogramDetails {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.license.LicenseManager {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.lite.AndroidLiteCardFactory {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.lite.LiteCardFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.ndef.Uri {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.ndef.Uri$? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.plus.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.ultralight.UltralightFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.utils.Utilities {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class org.apache.http.HttpHeaders {
    ();
    }

    -keepclassmembers !abstract class !com.google.ads.** extends android.view.View {
    public (android.content.Context);
    public (android.content.Context,android.util.AttributeSet);
    public (android.content.Context,android.util.AttributeSet,int);
    public void set*(...);
    }

    -keepclassmembers !abstract class * {
    public (android.content.Context,android.util.AttributeSet);
    public (android.content.Context,android.util.AttributeSet,int);
    }

    # Keep onClick handlers for Views and MenuItems as defined in resource xml files.
    -keepclassmembers class * extends android.content.Context {
    public void *(android.view.View);
    public *** *(android.view.MenuItem);
    }

    -keepclassmembers class * extends android.os.Parcelable {
    static ** CREATOR;
    }

    # Enumerations.
    -keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
    }

    # Serializable classes.
    -keepclassmembers class * extends 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();
    }

    -keepclassmembers class * extends android.os.Parcelable {
    public static final *** CREATOR;
    }


    Does anyone know what can I do? It has me stuck.
    Thanks a lot in advance.
    + 0  |  - 0

    Re: Error when I need generate signed APK

    18. September 2018 at 10:53
    Hi Liber,

    I copied your settings in my proguard-rules.pro file. I use AS 3.1.3. It worked. But I ask myself why do you repeat the line:

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }


    again and again? You can make it shorter to keep the entire TapLinx from obfuscation with:

    -keep class com.nxp.nfclib.** { *; }

    The TapLinx team

    + 0  |  - 0

    Re: Error when I need generate signed APK

    19. September 2018 at 2:49
    Hi, thanks for your reply.
    The problem is a directive "-android" In the line 4, I dont know why appears. There is some directive in the proguard configuration of the aar?
    I will detail all the configuration as I have it at this moment, nothing make special reference to com.nxp.nfclib:

    The proguard configuration in my app.gradle:
    Spoiler:

    .....
    .....
    buildTypes {
    release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    .....
    .....



    The proguard config it self (proguard-rules.pro):
    Spoiler:

    -optimizationpasses 5

    #When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
    -dontusemixedcaseclassnames

    #Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
    -dontskipnonpubliclibraryclasses

    #Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
    -dontpreverify

    #Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
    -verbose

    #The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
    #To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
    -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

    #To repackage classes on a single package
    #-repackageclasses ''

    #Keep classes that are referenced on the AndroidManifest
    -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 com.android.vending.licensing.ILicensingService


    #To remove debug logs:
    -assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    }

    #To avoid changing names of methods invoked on layout's onClick.
    # Uncomment and add specific method names if using onClick on layouts
    #-keepclassmembers class * {
    # public void onClickButton(android.view.View);
    #}

    #Maintain java native methods
    -keepclasseswithmembernames class * {
    native ;
    }

    #To maintain custom components names that are used on layouts XML.
    #Uncomment if having any problem with the approach below
    #-keep public class custom.components.package.and.name.**

    #To maintain custom components names that are used on layouts XML:
    #-keep public class * extends android.view.View {
    # public (android.content.Context);
    # public (android.content.Context, android.util.AttributeSet);
    # public (android.content.Context, android.util.AttributeSet, int);
    # public void set*(...);
    #}

    -keepclasseswithmembers class * {
    public (android.content.Context, android.util.AttributeSet);
    }

    -keepclasseswithmembers class * {
    public (android.content.Context, android.util.AttributeSet, int);
    }

    #Maintain enums
    -keepclassmembers enum * { *; }

    #To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
    -keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
    }

    #Keep the R
    -keepclassmembers class **.R$* {
    public static ;
    }

    ###### ADDITIONAL OPTIONS NOT USED NORMALLY

    #To keep callback calls. Uncomment if using any
    #http://proguard.sourceforge.net/index.html#/manual/examples.html#callback
    #-keep class mypackage.MyCallbackClass {
    # void myCallbackMethod(java.lang.String);
    #}

    #Uncomment if using Serializable
    #-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();
    #}

    -keepattributes Signature
    -keepattributes Annotation
    -dontwarn org.joda.time.**
    -dontwarn okio.**
    -dontwarn retrofit2.Platform$Java8



    The proguard.txt file, generated by the compiler:
    Spoiler:




    -android




    -keepclassmembers,allowobfuscation class com.nxp.nfclib.if {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.NxpNfcLib {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.analytics.AnalyticsTracker {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.classic.ClassicFactory {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.cloud.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.cloud.TrustIdCloudClient {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.defaultimpl.? {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.defaultimpl.SecureKeyGenerator {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.?$? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.DESFireFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.DESFireFile {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.EV1ApplicationKeySettings {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.EV1PICCKeySettings {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.EV2ApplicationKeySettings {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.MFPCard {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.MFPDESFireFile {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.desfire.MIFAREIdentityUtility {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.desfire.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.icode.ICodeFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.interfaces.CryptogramDetails {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.license.LicenseManager {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.lite.AndroidLiteCardFactory {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.lite.LiteCardFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.ndef.Uri {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.ndef.Uri$? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.plus.? {
    ();
    }

    -keepclassmembers,allowobfuscation class com.nxp.nfclib.ultralight.UltralightFactory {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class com.nxp.nfclib.utils.Utilities {
    ();
    }

    -keepclassmembers,allowoptimization,allowobfuscation class org.apache.http.HttpHeaders {
    ();
    }

    -keepclassmembers !abstract class !com.google.ads.** extends android.view.View {
    public (android.content.Context);
    public (android.content.Context,android.util.AttributeSet);
    public (android.content.Context,android.util.AttributeSet,int);
    public void set*(...);
    }

    -keepclassmembers !abstract class * {
    public (android.content.Context,android.util.AttributeSet);
    public (android.content.Context,android.util.AttributeSet,int);
    }

    # Keep onClick handlers for Views and MenuItems as defined in resource xml files.
    -keepclassmembers class * extends android.content.Context {
    public void *(android.view.View);
    public *** *(android.view.MenuItem);
    }

    -keepclassmembers class * extends android.os.Parcelable {
    static ** CREATOR;
    }

    # Enumerations.
    -keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
    }

    # Serializable classes.
    -keepclassmembers class * extends 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();
    }

    -keepclassmembers class * extends android.os.Parcelable {
    public static final *** CREATOR;
    }



    And the error detail:
    Spoiler:

    Unknown option '-android' in line 4 of file '/home/liberd/.gradle/caches/transforms-1/files-1.1/nxpnfcandroidlib-1.4.1.aar/dc237678e1ad1366a05b2415e5430e82/proguard.txt'


    Other info:
    Android Studio 3.1.4
    Build #AI-173.4907809, built on July 23, 2018
    JRE: 1.8.0_152-release-1024-b01 amd64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    Linux 4.13.0-46-generic

    Taplinx-android:nxpnfcandroidlib-1.4.1

    Thanks
    + 0  |  - 0

    Re: Error when I need generate signed APK

    19. September 2018 at 19:36
    Add another question, what version of gradle (com.android.tools.build:gradle) are you using? Im reading that the option -android was added in ProGuard 6.0 but the ProGuard version we use with android.tools.gradle is 4.7... Are you using manually different version of ProGuard?
    + 0  |  - 0

    Re: Error when I need generate signed APK

    20. September 2018 at 11:11
    Hi Liber

    We have an issue with the current TapLinx release (1.4.1) and the newest Android Studio. Therefore, you must use an older version of build tools:

    classpath 'com.android.tools.build:gradle:3.0.1'

    We use commercial software for making the final release of our software.

    The TapLinx team

    + 0  |  - 0
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.