Error when try sync gradle with new library - android

I have a problem with library. I copy `
compile ('de.psdev.licensesdialog:licensesdialog:1.8.0')
to gradle and when sync I get error:
Warning:Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (3.0.0) and test app (2.0.1) differ.
Any ideas how can I resolve my problem and use that library in my project.

I resolve my problem:
compile ('de.psdev.licensesdialog:licensesdialog:1.8.0') {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}

This happens because the main APK and the test APK use the same library (com.google.code.findbugs) but in different versions (your main APK use version 3.0.0 while your test APK use 2.0.1). So you need to tell to gradle to use for test the updated library.
Just add
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
to your gradle file :)

Related

Error: Program type already present when building project

I'm using an 'aar' library which I created.
In both, my project and the library, there is a dependency implementation of Conceal library (each from its own lib folder).
When I build the project after importing the library and using ProGuard obfuscation, I get this error message:
Error: Program type already present: com.facebook.crypto.cipher.NativeGCMCipher
How can I resolve this problem?
this error say you are importing the dependency which already imported in project.
solution :- remove or exclude this dependency
ex:-
compile ('com.github.ganfra:material-spinner:1.1.1'){
exclude group: 'com.nineoldandroids'
}
according to mavenCentral(), this is the package name (which could be used instead of .jar):
// https://mvnrepository.com/artifact/com.facebook.conceal/conceal
implementation "com.facebook.conceal:conceal:2.0.2"
therefore the exclusion should look about like this:
implementation( project(":libraryproject") ) {
exclude group: "com.facebook.conceal"
}
To my understanding, the error means that I imported a dependency that already imported in the project (once in the project and once in the library).
The suggested solutions of #Mayur Dabhi and #Martin Zeitler had the right approach, but unfortunately, I wasn't able to get the exclude command working.
finally, with the help of #Martin Zeitler, I replaced:
implementation files('libs/conceal_android.jar')
implementation files('libs/libconceal.jar')
with:
implementation "com.facebook.conceal:conceal:2.0.2"
meaning I removed the 'Conceal' jar files from the 'lib' folder and imported the dependency. After that, the error message disappeared and I managed to build the project.
Thanks for anyone who tried to help :)

Cloud Firestore with gRPC build error

I’m working on an android application, which have to use gRPC and Firestore. However, when I added both one of module from ‘io.grpc’ group dependency (e.g. io.grpc:grpc-okhttp:1.7.0) and firestore dependency (com.google.firebase:firebase-firestore:11.4.2) in the build gradle config, I got a build error “Unable to merge dex”. After with ‘stacktrace’ build option, I saw that the problem is
Multiple dex files define Lio/grpc/internal/OobChannel$5;
It could happen if firestore uses grpc-core module, but there is no one similar in tree dependencies, which I got using [androidDependencies] gradle task. I tried to exclude io.grpc like this:
implementation ('com.google.firebase:firebase-firestore:11.4.2') {
exclude group: 'io.grpc'
}
but there was the same error. Then I thought what if I exclude all ‘io.grpc.’ transitive dependencies from grpc module dependencies with adding grpc-core for internal classes. In this way, I wrote ugly dependencies just for test
implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation('io.grpc:grpc-okhttp:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-protobuf-lite:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-stub:1.7.0') {
exclude group: 'io.grpc'
}
implementation 'io.grpc:grpc-core:1.7.0'
I was surprised when it successfully compiled, but after launch app, it crashed with java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev)
Caused by: java.lang.NoSuchMethodError: No static method zzcyc()Lio/grpc/ManagedChannelProvider; in class Lio/grpc/ManagedChannelProvider; or its super classes (declaration of 'io.grpc.ManagedChannelProvider' appears in /data/app/com.zipr.test-2/split_lib_dependencies_apk.apk)
I use gradle 3.0.0-rc1 with enabling multidex support. I deleted .gradle, build directories, cleaned rebuilt project, but I still have build error. What can I do to resolve this problem?
Due to a variety of factors that constrain the way we build Android SDKs at Google, Firestore proguards a copy of gRPC within itself. Unfortunately this is leaky and you're running into the fallout: the 11.4.2 Firestore SDK is incompatible with any external gRPC :-(.
This is essentially our top issue for the Firestore Android SDK and I'm sorry you've run into it.

After upgrading to gradle 3.0.0-alpha5 libraries are not resolved at compile time

I recently upgraded to the new gradle 3.0.0-alpha5 after which some libraries are not resolved at compile time. However, all works fine at runtime, but when I try to include the missing libraries, I get runtime error.
this works at runtime but libraries are not resolved at compile time:
compile('jp.wasabeef:picasso-transformations:2.1.2') {
exclude group: 'com.squareup.picasso'
}
this resolves the libraries but fails at runtime:
compile 'jp.wasabeef:picasso-transformations:2.1.2'
I was having same problem recently. My workaround for the problem is as below.
First of all remove this library from the project and sync the project.
After successful sync you will get errors.
Now add this library again to the project and sync again.
Now your problem will be solved.

How can I find the dependencies in my app that are using findbugs? (findbugs conflict)

I'm trying to discover the specific conflict when adding espresso to my app's gradle file:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude group: 'com.android.support', module: 'support-annotations'
}
Android Studio states "Warning:Conflict with dependency 'com.google.code.findbugs:jsr305'.
Dependency conflict error in my Android app which has Android Tests states the error means the dependency I am using in my app is version 3.0.0 while the one in my test app is 2.0.1.
However, my gradle never explicitly adds "com.google.code.findbugs", indicating it was part of another dependency I added to my "compile" and "androidTestCompile" statements. How do I find the dependencies in my app that are using findbugs?
Check your dependencies:
HelloApp/
app/
- build.gradle // local gradle config (for app only)
...
- build.gradle // global gradle config (for whole project)
- settings.gradle
- gradle.properties
Check here:
dependencies {
compile project(':libraries:lib')
}
Later check this LINK you have Unit testing support orientation
Execute the following command:
./gradlew app:dependencies
This will print a (large) graph of dependencies.
For the meaning of the arrows and stars, please refer to this SO answer.

Using android gradle + dagger to run instrumentTests

I have began using Android Studio and gradle recently for android development and find it much better overall than eclipse/ant or maven. However I've recently began trying to implement some kind of unit and or integration tests with my app. I was able to get basic tests working using the Espresso framework recently released by google. I had some tests though where I needed to mock and inject mocked versions of objects. I used dagger in the past for another project so I included dagger into my project. However now my tests won't run because of the following error:
gradle connectedCheck
...
4.1.2 failed: Instrumentation run failed due to 'java.lang.IllegalAccessError' :EspressoApp:connectedCheck
I created a simple demo of this here:
https://github.com/mwolfe38/android-espresso-dagger
Just clone and then from command line run: gradle connectedCheck
In the above I have tried the dependencies several different ways, originally like this:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.dagger:dagger:1.1.0'
instrumentTestCompile files('libs/espresso-1.0-SNAPSHOT.jar',
'libs/testrunner-1.0-SNAPSHOT.jar',
'libs/testrunner-runtime-1.0-SNAPSHOT.jar')
instrumentTestCompile 'org.hamcrest:hamcrest-all:1.3'
instrumentTestCompile 'com.google.guava:guava:15.0'
}
but that gives me an error regarding static initialization. This appears to be caused by some static initialization code in the espresso framework regarding dagger. So After adding dagger dependencies to instrumentTestCompile I get the IllegalAccessError mentioned above.
Anyone have luck including dagger in your project and doing espresso tests?
Took quite awhile but I finally got it working. I had to do the following:
Declare my dependencies like so:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.dagger:dagger:1.1.0'
instrumentTestCompile files('libs/espresso-1.0-SNAPSHOT.jar','libs/testrunner-1.0-SNAPSHOT.jar','libs/testrunner-runtime-1.0-SNAPSHOT.jar')
instrumentTestCompile files('libs/hamcrest-core-1.1.jar', 'libs/hamcrest-library-1.1.jar', 'libs/hamcrest-integration-1.1.jar')
instrumentTestCompile 'com.google.guava:guava:14.0.1'
}
Copy the hamcrest jars from here
Remove the license files from the jars like this (or else you'll get an error about duplicate LICENSE.txt files)
zip -d hamcrest-core-1.1.jar LICENSE.txt
zip -d hamcrest-library-1.1.jar LICENSE.txt
Run gradle connectedCheck
A few things to note:
- Hamcrest 1.3 didn't work for me, got an error about a matcher was missing
- Crazy how many hoops I had to jump through to get here.
- Good luck getting this to play well with android studio.
Ok, so I have been dealing with this problem for hours, and here is my fix:
Put this in the dependencies of your build.gradle
compile(project(':commons:statemachine')) {
exclude module: 'junit'
exclude module: 'json'
exclude module: 'guava'
}
compile 'com.google.guava:guava:15.0'
instrumentTestCompile files('libs/espresso-1.0-SNAPSHOT-bundled.jar')
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
Add the espresso bundled jar in the libs folder of your test. Now comes the important part.
Open that espresso bundled jar with WinRar or equivalent and go to com/ folder, then select de android folder and Delete it. Now close WinRar and compile and run your test :-)

Categories

Resources