Evernote / evernote-sdk-android

Evernote SDK for Android
428 stars 168 forks source link

ProGuard causes TargetMethodFinder to fail #57

Open nathanvogel opened 8 years ago

nathanvogel commented 8 years ago

Hi, I'm not sure if this is just my ProGuard file that needs a fix, or maybe just the Evernote examples, but I think it should be fixed at the SDK level.

When this sample from the API example is executed, it downloads the list of notes, but stays loading forever. ADB logs only this warning : W/TargetMethodFinder: Didn't find method, result type interface java.util.List, result [com.evernote.client.android.c.a@bcea7c2, com.evernote.client.android.c.a@26b8d3, com.evernote.client.android.c.a@bcea7c2, com.evernote.client.android.c.a@30c7d4, ...long list of notes here.... com.evernote.client.android.c.a@11fe256, com.evernote.client.android.c.a@60d12d7], annotationId null, fragmentId 0/2131558519/null

which was sent from this library included in the EN SDK : https://github.com/vRallev/android-task/blob/master/library/src/main/java/net/vrallev/android/task/TargetMethodFinder.java#L87

Seems to occur a bit randomly, possibly in different places (I heard about weird bugs from users), but after some testing, I think it happens only in release mode when ProGuard is enabled.

I built the Demo with in release mode and was forced to modify the build config, but it also happens there. Here's what I added to the demo build.gradle file :

    signingConfigs {
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }

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

        release {
            minifyEnabled true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
            proguardFile 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

And proguard-rules.pro :

# --- Remove some warnings, as suggested by the warnings
# --- It won't compile without (at least some of) them
-dontwarn sun.misc.Unsafe
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn java.nio.file.*
-dontwarn org.scribe.services.DatatypeConverterEncoder
-dontwarn com.evernote.client.conn.mobile.TAndroidTransport
-dontwarn com.evernote.client.conn.mobile.DiskBackedByteStore
-dontwarn com.evernote.client.conn.mobile.ByteStore
-dontwarn org.scribe.services.CommonsEncoder
-dontwarn org.apache.commons.codec.binary.Base64

For now, my dumb fix is to set minifyEnabled false, because I simply have too many problems with ProGuard, but it would be great to either have a fix in the SDK or help me edit my ProGuard file.

Thanks