0

These are the test dependencies:

// tests
androidTestCompile 'org.mockito:mockito-all:1.10.8'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
androidTestCompile 'junit:junit:4.12'
androidTestCompile ('org.robolectric:robolectric:2.4') {
    exclude module: 'commons-logging'
    exclude module: 'httpclient'
}

And my debug build types has minifyEnabled true so as I don't hit a DEX method limit. The complete building is defined as following:

 defaultConfig {
    applicationId "com.example.myapp"
    minSdkVersion 15
    targetSdkVersion 22
    versionName VERSION_NAME

    proguardFile getDefaultProguardFile('proguard-android.txt')
    proguardFile 'proguard-rules.pro'
}

signingConfigs {
    debug {
        storeFile file('keystore/debug.keystore')

    }
}

productFlavors {
    develop {
        versionCode versionBuild()
        signingConfig signingConfigs.debug
        proguardFile 'proguard-rules-debug.pro'
    }
}

buildTypes {
    debug {
        minifyEnabled true
    }
}

There is a default proguard-rules.pro file and a additional proguard-rules-debug.pro for the flavor.

The :proguardDevelopDebug gradle task passes successfully based on the options I have. However the :proguardDevelopDebugAndroidTest fails with the following errors: http://pastebin.com/S623UGfP

Which is strange since I have added the following on the file:

-dontobfuscate

# ------------------- TEST DEPENDENCIES -------------------

-dontwarn org.hamcrest.**
-dontwarn com.squareup.**
-dontwarn com.google.android.**

-keep class com.google.android.** {
   *;
}
-keep class com.google.common.** {
   *;
}
-keep class org.hamcrest.** {
   *;
}

# Apache Maven
-keep class org.apache.maven.** { *; }
-dontwarn org.apache.maven.**

# Junit
-keep class org.junit.** { *; }
-dontwarn org.junit.**

# Mockito
-keep class org.mockito.** { *; }
-dontwarn org.mockito.**

# Robolectric
-keep class org.robolectric.** { *; }
-dontwarn org.robolectric.**

Any ideas why those two don't work together?

Diolor
  • 13,181
  • 30
  • 111
  • 179
  • 1
    You don't need proguard for robolectric. It runs on JVM and dex is not happening at all. Do you have problem of 64k methods for debug? What dependencies do you use? Proguarding debug is not really helpful operation – Eugen Martynov Mar 21 '15 at 20:35
  • @EugenMartynov Yes, as said above I hit the 65k limit. The list of dependencies is quite long and using `exclude` in some dependencies won't really help to avoid the use of proguard – Diolor Mar 21 '15 at 20:56
  • As for me proguard in debug is the last option to fix 65k issue. If you use play services then you could use exact part of services (http://www.reddit.com/r/androiddev/comments/2oo44w/google_play_services_6587_released_split_modules/). – Eugen Martynov Mar 21 '15 at 21:45
  • You could also create another build configuration with `debuggable = true` for Robolectric tests only and switch proguard for it – Eugen Martynov Mar 21 '15 at 21:46

0 Answers0