build failing on play-services:11.8.x with pro guard parser error

柔情痞子 提交于 2019-11-27 17:58:19

It seems the default shrinker has changed. Adding the configuration to turn on ProGuard seemed to work.

buildTypes {
        release {
            debuggable false
            minifyEnabled true
            useProguard true
            ...
        }
        debug {
            debuggable true
            minifyEnabled true
            useProguard true
            ...
        }
    }

In addition to the above solution (which works): the issue seems related to Instant Run as well. If you disable Instant Run, you can build your app without changing your build.gradle. Probably, the default shrinker has changed only when building for Instant Run.

This solution helped me:

First, in app/build.gradle change useProguard to 'true'

Second, in proguard rules add line '-dontobfuscate'

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

proguard-rules.pro

-dontobfuscate

So, minify would be work, but code wouldn't obfuscate.

I am noticing that if you disable Instant Run the build still fails with the same error (if you have minify enabled but Proguard disabled to shrink your code to avoid multi-dex in the debug build). If you follow Brill Pappin answer you must enable Instant Run(and install libraries as prompted) to hit any breakpoints while debugging.
It seems enabling the shrinker as described in the Google docs now only works if you are using Instant Run with the Google Play Play Services.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!