When I try and use dependencies I have set out in my build.gradle Intellij cannot build the code and raises errors java: cannot find symbol. How can I get Intellij to recognise my dependencies?
PS: The lbrary is showing up in "External Libraries" and I am also having this issue with all my other dependencies.
In my build.gradle I have this:
...
dependencies {
...
compile 'com.squareup.okhttp:okhttp:2.1.0'
}
In my code I try and use this library:
import com.squareup.okhttp.OkHTTPClient;
...
OkHTTPClient client = new OkHTTPClient();
errors raised on both lines.
EDIT from comment: Command line build fails with the same errors, I guess I wrongly blamed Intellij. How can I tell why the dependencies are not being downloaded? They are sitting in my build.gradle in dependencies just as I showed. They are also present when running gradle dependencies under compile, default, runtime, testCompile and testRuntime, but not archives. Is that where the issue lies?
EDIT2: Ouput of gradle dependencies:
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Classpath for compiling the main sources.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
default - Configuration for default artifacts.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
runtime - Classpath for running the compiled main classes.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
testCompile - Classpath for compiling the test sources.
+--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp:2.1.0
| \--- com.squareup.okio:okio:1.0.1
\--- junit:junit:4.11
\--- org.hamcrest:hamcrest-core:1.3
testRuntime - Classpath for running the compiled test classes.
+--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp:2.1.0
| \--- com.squareup.okio:okio:1.0.1
\--- junit:junit:4.11
\--- org.hamcrest:hamcrest-core:1.3
BUILD SUCCESSFUL
Total time: 1.82 secs
Related
In my project I am using MAP_IMPORTED_CONFIG_FINAL for an external library for a custom configuration FINAL. Is there some working example of how to set the target_link_directories for an imported target for the custom configuration FINAL using cmake.
So here are the steps :
The external library is boost-1.67.0 which I am installing using the following commands for Debug and Release respectively:
.\bootstrap.bat
.\b2 install --prefix=C:\Dev\third-party\vs2017\boost-1.67.0\Debug toolset=msvc-14.1 address-model=64 link=static -j8 variant=debug
.\b2 install --prefix=C:\Dev\third-party\vs2017\boost-1.67.0\Release toolset=msvc-14.1 address-model=64 link=static -j8 variant=release
Here is the example project with following structure
boost-example/
|
+-- main.cpp
|
+-- CMakeLists.txt
|
|
+-- CMake/
| |
| +-- AddConfiguration.cmake
| +-- mpIncludeBoost.cmake
| +-- mpSetupMSVCRuntime.cmake
| +-- SetupConfigurations.cmake
The files are found in this gitlab project: https://gitlab.com/sunayanag/boost-example.
For the sln file generated note that in Visual Studio in the Linker section in Additional Library Directories I get C:/Dev/third-party/boost-1_67_0/install/lib/$(Configuration) which evaluates to C:/Dev/third-party/boost-1_67_0/install/lib/Final but this directory does not exist since Final is not a valid configuration of boost, it should be C:/Dev/third-party/boost-1_67_0/install/lib/Release instead.
I was thinking a way of getting around this would be to use target_link_directories but how do I use this with cmake generator expressions in this case.
Thanks
I'm trying to use Fuel JSON deserializer so I added it to my dependencies like this:
implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
implementation 'com.github.kittinunf.fuel:fuel-json:2.2.1'
However each time I'm running ./gradlew clean build I'm getting this error:
> Task :compileKotlin FAILED
e: /DirToMyClass/MyClass.kt: (55, 26): Cannot access class 'org.json.JSONObject'. Check your module classpath for missing or conflicting dependencies
I've run ./gradlew dependencies to check that there are no other dependency importing org.json and the only one is fuel-json.
+--- com.github.kittinunf.fuel:fuel-json:2.2.1
| +--- com.github.kittinunf.fuel:fuel:2.2.1 (*)
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 -> 1.3.60 (*)
| \--- org.json:json:20180813
What can I be missing?
I've fixed this by changing the dependencies to:
implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
implementation('com.github.kittinunf.fuel:fuel-json:2.2.1') {
exclude group: 'org.json', module: 'json'
}
implementation 'org.json:json:20190722'
Using a newer version of org.json:json.
I am attempting to test my Android app (on device), but during the gradle build process I am getting "Error: Program type already present: com.google.protobuf.AnyProto" (or other classes).
I am using Google Firebase-Firestore DB, which implements grpc and uses nested dependency: com.google.protobuf:protobuf-lite:3.0.1.
Also, the google/Capillary library uses nested dependency: com.google.protobuf:protobuf-java:3.4.0.
If I exclude com.google.protobuf from the Capillary lib dependency only, the app will run, then crash when a needed Capillary class is instantiated, with error: "java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;"
Here are my app dependencies, without exclusions:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
//HERE ARE THE PROBLEM DEPENDENCIES:
implementation('com.google.firebase:firebase-firestore:18.2.0', {})
implementation('com.google.capillary:lib-android:1.0.0', { })
//
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And here is the (tree) readout of gradlew app:dependencies:
...{CONTENT ABOVE OMITTED}...
+--- com.google.firebase:firebase-firestore:18.2.0
| +--- com.google.android.gms:play-services-base:16.0.1 (*)
| +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.2.0 (*)
| +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
| +--- com.google.firebase:firebase-auth-interop:16.0.1 (*)
| +--- com.google.firebase:firebase-common:16.1.0 (*)
| +--- com.google.firebase:firebase-database-collection:16.0.1
| +--- com.google.firebase:protolite-well-known-types:16.0.1
| | \--- com.google.protobuf:protobuf-lite:3.0.1
| +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
| +--- com.squareup.okhttp:okhttp:2.7.5
| | \--- com.squareup.okio:okio:1.6.0 -> 1.13.0
| +--- io.grpc:grpc-android:1.16.1
| | \--- io.grpc:grpc-core:[1.16.1] -> 1.16.1
| | +--- io.grpc:grpc-context:1.16.1
| | +--- com.google.code.gson:gson:2.7
| | +--- com.google.errorprone:error_prone_annotations:2.2.0
| | +--- com.google.code.findbugs:jsr305:3.0.2
| | +--- org.codehaus.mojo:animal-sniffer-annotations:1.17
| | +--- com.google.guava:guava:26.0-android
| | | +--- org.checkerframework:checker-compat-qual:2.5.2
| | | \--- com.google.j2objc:j2objc-annotations:1.1
| | +--- io.opencensus:opencensus-api:0.12.3
| | | \--- com.google.errorprone:error_prone_annotations:2.2.0
| | \--- io.opencensus:opencensus-contrib-grpc-metrics:0.12.3
| | +--- com.google.errorprone:error_prone_annotations:2.2.0
| | \--- io.opencensus:opencensus-api:0.12.3 (*)
| +--- io.grpc:grpc-okhttp:1.16.1
| | +--- io.grpc:grpc-core:[1.16.1] -> 1.16.1 (*)
| | +--- com.squareup.okhttp:okhttp:2.5.0 -> 2.7.5 (*)
| | \--- com.squareup.okio:okio:1.13.0
| +--- io.grpc:grpc-protobuf-lite:1.16.1
| | +--- io.grpc:grpc-core:1.16.1 (*)
| | +--- com.google.protobuf:protobuf-lite:3.0.1
| | \--- com.google.guava:guava:26.0-android (*)
| \--- io.grpc:grpc-stub:1.16.1
| \--- io.grpc:grpc-core:1.16.1 (*)
\--- com.google.capillary:lib-android:1.0.0
+--- com.google.capillary:lib:1.0.0
| \--- com.google.protobuf:protobuf-java:3.4.0
+--- com.google.crypto.tink:tink-android:1.1.0
+--- com.google.crypto.tink:apps-webpush:1.1.0
+--- com.google.protobuf:protobuf-java:3.4.0
+--- joda-time:joda-time:2.9.9
\--- com.android.support:support-annotations:27.1.1 -> 28.0.0
I have tried using several combinations of package exclusions, including fully excluding com.google.protobuf from both Firestore and Capillary and implementing either separately:
implementation('com.google.protobuf:protobuf-java:3.4.0')
//{OR}
//implementation('com.google.protobuf:protobuf-lite:3.0.1')
implementation('com.google.firebase:firebase-firestore:18.2.0', {
exclude group: 'com.google.protobuf'//, module: 'protobuf-lite'
})
implementation('com.google.capillary:lib-android:1.0.0', {
exclude group: 'com.google.protobuf'//, module: 'protobuf-java'
})
^I have tried several combinations of this, with no success.
When I exclude 'com.google.protobuf' only from the Capillary lib dependency (I am not using the grpc functionality of this library), I am able to get the app to run, however, it does crash when a necessary object from the Capillary library is instantiated, with error: "java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;"
Is anyone able to help me sort this out so that there are no redundant dependencies nor missing class definitions, without breaking the functionality of the Capillary dependency?
Recently I updated all my versions in the build.gradle file and still the build fails every time.
I get this error message
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
I have tried all of the solutions suggested in other posts like:
Gradle sync fails - play-services-measurement-base
Android Studio Error The library com.google.android.gms:play-services-measurement-base
com.google.android.gms:play-services-measurement-base is being requested by various other libraries
Unfortunately, nothing worked, and I am desperate.
I am using react native with Firebase and Firestore.
Got this same error and have been stuck on it all week. I had this problem with another library and ended up having to manually change the version of the conflicting library. In that case, ./gradlew :app:dependencies was able to highlight which package it was. In this case, it does not.
All I'm seeing in the analyze depenedencies call is
com.google.firebase:firebase-core:16.0.1
| +--- com.google.firebase:firebase-analytics:16.0.1 (*)
| \--- com.google.firebase:firebase-measurement-connector-impl:16.0.1
| +--- com.google.android.gms:play-services-basement:15.0.1 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.0] -> 16.0.0
| +--- com.google.firebase:firebase-analytics:[16.0.1] -> 16.0.1 (*)
| +--- com.google.firebase:firebase-analytics-impl:[16.1.1] -> 16.1.1 (*)
| +--- com.google.firebase:firebase-common:16.0.0 (*)
| \--- com.google.firebase:firebase-measurement-connector:16.0.0
| \--- com.google.android.gms:play-services-basement:15.0.1 (*)
\--- com.google.firebase:firebase-messaging:17.0.0
+--- com.google.android.gms:play-services-basement:15.0.1 (*)
+--- com.google.android.gms:play-services-tasks:15.0.1 (*)
+--- com.google.firebase:firebase-common:16.0.0 (*)
+--- com.google.firebase:firebase-iid:[16.0.0] -> 16.0.0 (*)
\--- com.google.firebase:firebase-measurement-connector:16.0.0 (*)
which hints that its resolving at 16.0.1 which what I intended..
compile ("com.google.firebase:firebase-analytics:16.0.1") {
force = true
}
Here's my error:
* What went wrong:
Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.1,16.0.1]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
In a JavaFX Gradle-based application that I develop using RxJava and Kotlin in IntelliJ IDEA 2017.1.2 (Build #IC-171.4249.39), I'm getting an exception:
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/reactivestreams/Publisher
everytime a code like this
return Completable.complete()
is executed. Following a suggestion of a similar question Why I am getting NoClassDefFoundError: org/reactivestreams/Publisher, I've tried to add include the reactive-streams to the dependencies block of my build.gradle script
dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.2'
compile 'org.reactivestreams:reactive-streams:1.0.0'
compile 'io.reactivex.rxjava2:rxkotlin:2.0.0'
}
but the problem persists. The dependency tree looks like this one:
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
compileClasspath - Compile classpath for source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
\--- org.jetbrains.kotlin:kotlin-annotation-processing:1.1.2
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
\--- org.jetbrains:annotations:13.0
kaptTest
\--- org.jetbrains.kotlin:kotlin-annotation-processing:1.1.2
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
\--- org.jetbrains:annotations:13.0
runtime - Runtime dependencies for source set 'main' (deprecated, use 'runtimeOnly ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
testCompileClasspath - Compile classpath for source set 'test'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
testRuntime - Runtime dependencies for source set 'test' (deprecated, use 'testRuntimeOnly ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
| \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.7
| \--- org.reactivestreams:reactive-streams:1.0.0
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)
As you can see, org.reactivestreams:reactive-streams is present in each environment.
Now, I've managed to resolve the problem by adding manually dependency on a reactive-streams-1.0.0.jar, but I don't like this solution at all.
Could somebody advice a better solution? Thanks!