0

I have been using DexGuard successfully with Gradle in Android Studio without any issues. I recently tried my hands on OkBuck to speed up my build time and it really helped me.

Although it is able to build debug and signed APKs for me, but when I try building for release with DexGuard like:

./buckw install --run app:bin_release

I get the following error:

Error: Unknown option '-dalvik' in line 9 of file 'SomeApp/app/build/okbuck/release/proguard.pro',
  included from line 60 of file 'buck-out/gen/app/bin_release/proguard/command-line.txt',
  included from argument number 1

BUILD FAILED: //app:bin_release failed with exit code 1:
proguard_obfuscation
stderr: Error: Unknown option '-dalvik' in line 9 of file 'SomeApp/app/build/okbuck/release/proguard.pro',
  included from line 60 of file 'buck-out/gen/app/bin_release/proguard/command-line.txt',
  included from argument number 1

It is probably insignificant to mention the details of DexGuard integration as it is done as per the documentation and is working fine when I build from within Android Studio or using ./gradlew, but here it is:

SomeApp/build.gradle:

buildscript {
    ext {
        DEXGUARD_HOME = "$System.env.DEXGUARD_HOME"
    }

...    

SomeApp/app/build.gradle:

buildTypes {
    ...

    release {
         minifyEnabled true
         proguardFile DEXGUARD_HOME + "Dexguard-7.3.11/lib/dexguard-release-aggressive.pro"
         proguardFile 'dexguard-project.txt'
         signingConfig signingConfigs.release
     }
}
Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
  • i am facing some issue with okBuck. buckw command is not working. Included dependencies NDK and watchman as mentioned in the okBuck github. Created buck wrapper but the buckw commands are not getting recognised in android studio terminal. Any ideas would be really helpful. Thanks – Firnaz May 21 '19 at 06:43

1 Answers1

2

The message typically indicates that ProGuard is still enabled -- ProGuard doesn't know the DexGuard option -dalvik. You should leave minifyEnabled set to false. DexGuard itself already shrinks, optimizes, and obfuscates all code and resources.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • I changed `minifyEnabled` to `false`, it seems to have built without DexGuard... (the APK size after DexGuarding is around 4 MBs, but this built 7+ MBs) I hope I am not missing anything. – Kamran Ahmed Apr 03 '17 at 12:33
  • I assume you've specified `apply: 'dexguard'` in your build file, since it works in a standard Gradle build. OkBuck may be interfering with the tasks that it sets up -- I don't know at this time. – Eric Lafortune Apr 03 '17 at 13:17
  • Yup, `apply plugin: 'dexguard'` is setup properly. It would be really great if I could make my release builds with `OkBuck` as that is the most time-consuming build for this project. I understand that DexGuarding will take its time, but I guess my release builds will be at least a bit faster. – Kamran Ahmed Apr 03 '17 at 13:23
  • i am facing some issue with okBuck. buckw command is not working. Included dependencies NDK and watchman as mentioned in the okBuck github. Created buck wrapper but the buckw commands are not getting recognised in android studio terminal. Any ideas would be really helpful. – Firnaz May 21 '19 at 06:59