How to make Kotlin Fuel json serializer to compile? - kotlin

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.

Related

pkg_config_modules dependency fails because version in "Uncontrolled"

The Problem
I've got a CMakeLists.txt file with this content:
pkg_check_modules(FOO REQUIRED foo>=0.1.0.1)
When I run Cmake v3.17.2 with cmake3 -G Ninja . in that directory:
Checking for module 'foo>=0.1.0.1'
Requested 'foo >= 0.1.0.1' but version of foo is Uncontrolled
Details
This is running inside RHEL7
yum info foo | grep Version returns Version : 0.1.0.1.20200417git602d018
The foo module is created by the team I'm on
The Question
How can I tell CMake what version my foo library is so that it isn't "Uncontrolled"?
In the output of the foo project, inside of the generated lib64 directory, there's a pkgconfig directory which contains foo.pc.
Inside of that file, version info is as follows:
Version: HEAD
Change this to be the intended version. In my case this was automated by the build process of foo, so what was required was to add a git tag for the current version and rebuild.

target_link_directories for imported targets

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

Firebase - Gradle failed on build - com.google.android.gms:play-services-measurement-base

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.

Cannot generate new project using yeoman generator Gradle+Kotlin

I installed Android Studio on Mac using brew install Caskroom/cask/android-studio
Then, I run yo gradle-kotlin, and got the following error. What can I do to make my first Hello World work?
Thank you
✔ /Volumes/Git/android/kotlin-hello-world
10:53 $ yo gradle-kotlin
_-----_
| | .--------------------------.
|--(o)--| | Welcome to the |
`---------´ | incredible Gradle+Kotlin |
( _´U`_ ) | generator! |
/___A___\ '--------------------------'
| ~ |
__'.___.'__
´ ` |° ´ Y `
Detecting installed Gradle version...
Fetching latest Kotlin version from Maven Central...
✔ Fetched latest Kotlin version: 1.0.1-2
✔ Detected installed Gradle version: 2.12
? What's your project name? kotlin hello world
? What Gradle version would you like to use? 2.12
? What Kotlin version would you like to use? 1.0.1-2
? Do you want to use Kotlin Reflection? Yes
? Would you like to use IDEA Gradle plugin? Yes
identical .gitignore
identical src/main/kotlin/.gitkeep
identical src/test/kotlin/.gitkeep
identical build.gradle
identical gradle.properties
identical settings.gradle
Executing 'gradle wrapper' command...
✔ Done executing 'gradle wrapper' command.
Executing Gradle tasks: idea build
internal/child_process.js:298
throw errnoException(err, 'spawn');
^
Error: spawn EACCES
at exports._errnoException (util.js:856:11)
at ChildProcess.spawn (internal/child_process.js:298:11)
at Object.exports.spawn (child_process.js:362:9)
at Function.spawn (/usr/local/lib/node_modules/generator-gradle-kotlin/node_modules/cross-spawn-async/index.js:13:18)
at spawn (/usr/local/lib/node_modules/generator-gradle-kotlin/node_modules/cross-spawn/index.js:34:23)
at GradleKotlinGenerator.spawnCommand (/usr/local/lib/node_modules/generator-gradle-kotlin/node_modules/yeoman-generator/lib/actions/spawn_command.js:20:10)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/generator-gradle-kotlin/generators/app/gradle-kotlin.coffee:78:8)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
I've just fixed it.
It was an OSX-specific bug in the generator logic, a rather stupid one: it incorrectly detected the platform and tried to call ./gradlew.bat, it didn't even realize it's a .bat file, the reason for EACCES error actually was that this .bat didn't have +x permission. Just update the generator to 1.1.1 and it should be fine.

Intellij downloads Gradle dependencies but cannot resolve symbols

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