facebook / buck

A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.
https://buck.build
Apache License 2.0
8.56k stars 1.16k forks source link

ProGuard config not work for buck #483

Closed Piasy closed 9 years ago

Piasy commented 9 years ago

I'm trying to use buck to do release build, and the proguard config works fine for gradle build, but buck build fail. Below is my android_binary rule:

android_binary(
    name = 'bin',
    manifest = ':manifest',
    keystore = '//.okbuck/keystore/app:key_store',
    package_type = 'release',
    proguard_config = 'proguard-rules.pro',
    android_sdk_proguard_config = 'none',  # even not use sdk proguard config doesn't work
    deps = [
        ':res',
        ':src',
    ],
    visibility = [
        'PUBLIC',
    ],
)

buck install app fails with error message:

...
Note: android.support.v4.text.ICUCompatApi23: can't find dynamically referenced class libcore.icu.ICU
...
Note: android.support.v4.app.NotificationCompatJellybean accesses a declared field 'title' dynamically
      Maybe this is program field 'android.support.design.R$attr { int title; }'
...
Warning: butterknife.internal.ButterKnifeProcessor: can't find superclass or interface javax.annotation.processing.AbstractProcessor
...
Warning: com.pushtorefresh.storio.internal.ChangesBus: can't find referenced class rx.Observable
...
Warning: there were 375 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars').
Warning: there were 2 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile them and try again.
         Alternatively, you may have to specify the option
         '-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:321)
    at proguard.ProGuard.initialize(ProGuard.java:211)
    at proguard.ProGuard.execute(ProGuard.java:86)
    at proguard.ProGuard.main(ProGuard.java:492)

Full demo project is here: https://github.com/Piasy/OkBuck/tree/9096d27e29c2f91d92e46b78d25b5f8b4f229604.

sdwilsh commented 9 years ago

Setting android_sdk_proguard_config to 'none' looks suspicious. Your comment there implies to tried setting to to something else; was that 'optimized'?

Piasy commented 9 years ago

@sdwilsh Before I report this issue, first time I didn't set android_sdk_proguard_config parameter, buck build app failed with the same error message above, then I tried to set android_sdk_proguard_config = 'none', nothing changed.

But the really strange things is, today when I remove android_sdk_proguard_config parameter, it works! and setting to 'optimized', it works too, but take more time to finish build, and setting to 'none' will fail with the error message above. Really strange...

sdwilsh commented 9 years ago

I think that was the expected behavior. If you set it to 'none', the default configuration isn't going to be loaded at all.

Piasy commented 9 years ago

@sdwilsh Yes I understand that, what bothered me was before I open this issue, it didn't work even when I didn't set android_sdk_proguard_config parameter, but after a week, it just works. Maybe I missed something, anyway, it works fine, that's good.