1

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.

Ably's site 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 this question, 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 this and this. I also tried changing the build hint key to android.gradleDep, but nothing changed.

Here's what it looks like on Netbeans: enter image description here

Here's the build hints window: enter image description here

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

Bom Tomdabil
  • 61
  • 1
  • 10

1 Answers1

2

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';

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I changed it like you said and nothing changed. I also restarted Netbeans; that didn't do anything either. – Bom Tomdabil Sep 06 '18 at 14:02
  • 1
    Notice that code completion and highlighting won't work when you are working with NetBeans on native code. But it will compile in the build server fine. See https://www.codenameone.com/how-do-i---access-native-device-functionality-invoke-native-interfaces.html – Shai Almog Sep 07 '18 at 03:07
  • 1
    I clicked 'Send Android build' on my project, but it still gives me the `package io.ably.lib.types does not exist` error and fails to compile and build. I researched it, but didn't find anything that helped. Thanks for taking the time to help me out. :) – Bom Tomdabil Sep 07 '18 at 15:23
  • Did it give you this error in the server or in the client? If in the server can you include the full error log link? (make sure it doesn't expire). If in the client you need to make sure to only use that package within the native code under the `native/android` directory. It will only be reachable to Codename One via the native interface. You can see a lot of samples for abstracting native libraries in Codename One in the source code of the cn1libs https://www.codenameone.com/cn1libs.html – Shai Almog Sep 08 '18 at 04:15
  • Sorry for the late reply; I've really been trying to figure this out. I got the error in Netbeans, so I downloaded the Ably SDK [here](https://www.ably.io/download), and put it under `project/native/android` (I tried it as a .zip and as an extracted folder), but nothing changed. I get the `package io.ably.lib.types does not exist` error in Netbeans when I click `refresh cn1lib files`. I followed the link you sent, and didn't find Ably in the list of libraries, but it did say that I can submit my own cn1lib. Is that what I need to do? I looked, but couldn't find out how to do that. Thanks! – Bom Tomdabil Sep 10 '18 at 03:32
  • You can't just put the SDK there, you need to put either a JAR or AAR there. Or alternatively work with the gradle build hint. Assuming the build fails I'll need the link to the build log as it would contain the information I need to track down your problem – Shai Almog Sep 10 '18 at 05:06
  • I couldn't build a JAR from Ably's SDK, so I've spent the past few days talking to the support folks at Ably. They told me that they somehow ended up without a `gradle.bat` in the root, and until that gets resolved in the next release, I won't be able to build a JAR. Thank you so much for taking the time to help me get this far though! – Bom Tomdabil Sep 12 '18 at 16:34