22178

Cannot add Gradle dependencies to my Codename One Project

Question:

I'm building a simple online app with Netbeans using Codename One, and I wanted to use Ably for internet communication, but I'm having trouble importing the Ably API.

<a href="https://www.ably.io/documentation/quick-start-guide" rel="nofollow">Ably's site</a> tells me that I need to add the line compile 'io.ably:ably-java:1.0.0' to the build.gradle dependencies section, but there is no build.gradle in my project. After seeing <a href="https://stackoverflow.com/questions/35549182/how-to-add-gradle-library-dependency-to-a-codenameone-project?rq=1" rel="nofollow">this question</a>, I added a new build hint with gradleDependencies as the key and compile 'io.ably:ably-java:1.0.0' as the value.

When I try to run the project, though, it still fails and tells me error: package io.ably.lib.types does not exist import io.ably.lib.types.*;.

I did some more research, but everything seems to say that I did the right thing, like <a href="https://www.codenameone.com/blog/tip-use-android-gradle-dependencies-native-code.html" rel="nofollow">this</a> and <a href="https://stackoverflow.com/questions/46183573/how-do-i-add-dependencies-to-the-root-level-build-gradle-file-in-my-codename-one/46185115" rel="nofollow">this</a>. I also tried changing the build hint key to android.gradleDep, but nothing changed.

Here's what it looks like on Netbeans: <a href="https://i.stack.imgur.com/RcSqc.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/RcSqc.png" data-original="https://i.stack.imgur.com/RcSqc.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Here's the build hints window: <a href="https://i.stack.imgur.com/lHwUN.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/lHwUN.png" data-original="https://i.stack.imgur.com/lHwUN.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

If you need any more info, please let me know. Thanks!

Answer1:

The build hint should be android.gradleDep not gradleDep as it's an Android specific flag.

I would recommend adding a semicolon at the end of the dependency too e.g.: compile 'io.ably:ably-java:1.0.0';

Recommend

  • Rails Route parameters in AngularJS
  • Should I optimize around reads or CPU time in Google App Engine
  • Equivalent of branch..merge for git-push
  • css font-size and line-height not matching the baseline
  • How to load Q library with Require.js?
  • Graceful pod termination
  • insert a picture into database(sqlite) with java code. what should i do?
  • PHP UTF-8 to GB2312
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • Unzip archive in .Net CORE 1.0
  • Better Indy for Dephi 2007
  • How to pass solution folder as parameter in command line arguments (for debug)?
  • Django Haystack Rebuild Index
  • Aptana 3 remove bundle (jquery)
  • Does Apportable support to build library binary (.a/.so)?
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • NUnit 3.0 TestCase const custom object arguments
  • Uncaught TypeError: $(…).select2 is not a function
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Unable to install Git-core+svn by MacPorts
  • Groovy: Unexpected token “:”
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Switching to Release Build causes runtime error in Web Reference
  • Using $this when not in object context
  • Read text file and split every line in MSBuild
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Cross-Platform Protobuf Serialization
  • SSO with signing and signature validation doesn't work
  • Perl system calls when running as another user using sudo
  • Why winpcap requires both .lib and .dll to run?
  • QuartzCore.framework for Mono Develop
  • How to format a variable of double type
  • Angular 2 constructor injection vs direct access
  • coudnt use logback because of log4j
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Qt: Run a script BEFORE make
  • JaxB to read class hierarchy
  • UserPrincipal.Current returns apppool on IIS