Just right after writing my question, I found an answer. Changing the "compile" scope to "build" should resolve the error:
build 'com.google.apis:google-api-services-analytics:v3-rev74-1.17.0-rc'
Actually this solved my previous problem, but raised another one :) A "build" scope includes the library only when compiling, but not at runtime! So I didn't have google-api-services-analytics available when deployed to Tomcat. My final and working solution is:
dependencies {
def googleLibVersion = "1.17.0-rc"
compile("com.google.apis:google-api-services-analytics:v3-rev74-${googleLibVersion}") {
excludes "commons-codec"
}
compile("com.google.http-client:google-http-client-jackson2:${googleLibVersion}") {
excludes "commons-codec"
}
}