Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal dependency conflict appears when compiling google-cloud-pubsub #1319

Closed
kir-titievsky opened this issue Oct 17, 2016 · 7 comments
Closed
Assignees

Comments

@kir-titievsky
Copy link

Reposting this submission to [email protected] as a bug:

The cloud pubsub library is not working with Android Studio 2.2.1 (Build #AI-145.3330264, built on October 6, 2016, JRE: 1.8.0_76-release-b03 amd64, JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o) under Debian (3.2.0-4-amd64 #1 SMP Debian 3.2.81-2 x86_64 GNU/Linux).

I added [compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.4.0'] to gradle file, but it states the following: "Execution failed for task ':app:prepareDebugAndroidTestDependencies'.>Dependency Error. See console for details."

I checked the console and the output shows the following: "Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (3.0.0) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.".

I tried to solve it by adding the following line to the android{} section of gradle file: "configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0' }", but it resulted in the following output in console(see below):
"Error:FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

    com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File1: /home/debi/.gradle/caches/modules-2/files-2.1/com.google.auto.value/auto-value/1.1/f6951c141ea3e89c0f8b01da16834880a1ebf162/auto-value-1.1.jar
    File2: /home/debi/.gradle/caches/modules-2/files-2.1/org.codehaus.jackson/jackson-core-asl/1.9.11/e32303ef8bd18a5c9272780d49b81c95e05ddf43/jackson-core-asl-1.9.11.jar
    File3: /home/debi/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/4.0/f990a43d3725781b6db7cd0acf0a8b62dfd1649/guice-4.0.jar

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. "

What should I do?

@mziccard
Copy link
Contributor

@kir-titievsky I'll try to have a look at this. First and second errors appear to be unrelated though. Also please, be aware that we do not explicitly support Android at the moment.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE

This kind of duplication errors seems to be quite common in Android. To avoid duplication you could try adding to your build file:

packagingOptions {
    exclude 'META-INF/LICENSE'
}

@jfarkhat
Copy link

Hi,

Just want to update it with the recent gradle configuration:

Gradle:

apply plugin: 'com.android.application'

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'

}

android {
compileSdkVersion 23
buildToolsVersion '24.0.3'
defaultConfig {
applicationId "com.example.debi.pubsub0"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

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

configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
}

packagingOptions {
    pickFirst 'META-INF/LICENSE'
    pickFirst  'META-INF/io.netty.versions.properties'
    pickFirst 'META-INF/INDEX.LIST'
}

/*packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude  'META-INF/io.netty.versions.properties'
    exclude 'META-INF/INDEX.LIST'
}*/

}

Console:

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.
Error:trouble processing "javax/transaction/HeuristicCommitException.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting

Information:BUILD FAILED

Some warnings have been suppressed using 'pickFirst' or 'exclude' methods, but it doesn't seem to go beyond that. The problem disappears only if "compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.4.0'" gets removed from dependencies(other libraries work fine).

Thanks.

@mziccard
Copy link
Contributor

mziccard commented Oct 17, 2016

Hi @jfarkhat,
try replacing:

compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.4.0'

with:

compile ('com.google.cloud:google-cloud-pubsub:0.4.0') {
    exclude group: 'com.google.api-client', module: 'google-api-client-appengine'
}

This should exclude the dependency that is causing troubles.

@mziccard
Copy link
Contributor

Could you please format your previous posts? Also please don't cut-and-paste these long logs but rather attach a public gist to your post.

Are you excluding other artifacts in addition to the one I suggested you to exclude?

@jfarkhat
Copy link

jfarkhat commented Oct 18, 2016

I am sorry :)))

Here is the output2 from adding the 3rd line of the code to MainActivity:
PubSubOptions.Builder optionsBuilder = PubSubOptions.builder();
optionsBuilder.projectId("project-id");
PubSub pubsub = optionsBuilder.build().service();

https://gist.github.com/jfarkhat/3fcdce92eba2a918ef6163c89a3f9913

I excluded 'group: 'com.google.api-client', module: 'google-api-client-appengine'

@mziccard
Copy link
Contributor

@jfarkhat I had a deeper look at this, try adding this dependency:

compile group: 'com.google.api-client', name: 'google-api-client', version: '1.21.0'

@jfarkhat
Copy link

Hi,
Compile group: 'com.google.api-client', name: 'google-api-client', version: '1.21.0' didn't work(the same errors). But the issue is no longer a problem and I found much simpler solution to it. Thanks )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants