Open Source & Free  

TIP: Use Android Gradle Dependencies in Native Code

TIP: Use Android Gradle Dependencies in Native Code

Header Image

Integrating a native OS library isn’t hard but it sometimes requires some juggling. Most instructions target developers working with xcode or Android Studio & you need to twist your head around them. In Android the steps for integration in most modern libraries include a gradle dependency.

E.g. we recently published a library that added support for Intercom. The native Android integration instructions for the library looked like this:

Add the following dependency to your app’s build.gradle file:

dependencies {
    compile ''

Which instantly raises the question: “How in the world do I do that in Codename One”?

Well, it’s actually pretty simple. You can add the build hint:

android.gradleDep=compile ''

This would “work” but there is a catch…​

You might need to define the specific version of the Android SDK used and specific version of Google play services version used. Intercom is pretty sensitive about those and demanded that we also add:


Once those were defined the native code for the Android implementation became trivial to write and the library was easy as there were no jars to include.

Leave a Reply