JARs for com.couchbase.couchbase-lite-android-ee-3.1.6 not found in Maven repo

Hi folks, added dependency com.couchbase.lite:couchbase-lite-android:3.1.6 and repo https://mobile.maven.couchbase.com/maven2/dev/ for my React Native for Android project. Seems the POM file is there in the repo, but not the JAR file itself.

This is Android. You need an aar. It is there:
https://mobile.maven.couchbase.com/maven2/dev/com/couchbase/lite/couchbase-lite-android-ee/3.1.6/couchbase-lite-android-ee-3.1.6.aar

Thanks so much Blake. I was able to download the AAR.

FWIW, this information is in the pom. See the last line in this snippet

<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.couchbase.lite</groupId>
  <artifactId>couchbase-lite-android-ee</artifactId>
  <version>3.1.6</version>
  <packaging>aar</packaging>

Well this React Native project relies on Gradle instead. But thanks. It’s currently unable to find the AAR file, and I am trying to solve that.

FYI I refer to the instructions here

I see. I am not involved with that documentation. I would say, though, that it is remarkably out of date. There is no reason for you to have to download the aar file: Gradle uses the Maven protocol and will pull it from our maven server. Just add the address of our maven server to your build.gradle file:

repositories {
    maven { url 'https://mobile.maven.couchbase.com/maven2/dev' }
    google()
    mavenCentral()
}

Thanks Blake. Does this work for you ?
mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get -DremoteRepositories=couchbase::::https://mobile.maven.couchbase.com/maven2/dev/ -Dartifact=com.couchbase.lite:couchbase-lite-android-ee:3.1.6

In my case the POM (couchbase-lite-android-ee-3.1.6.pom) is successfully downloaded, but not the JAR itself:

Downloading from couchbase: https://mobile.maven.couchbase.com/maven2/dev/com/couchbase/lite/couchbase-lite-android-ee/3.1.6/couchbase-lite-android-ee-3.1.6.jar

Something that works for you is all that matters.

If it were me, I wouldn’t be doing anything so complicated. I’d just put this in my build.gradle:


repositories {
    maven { url "https://mobile.maven.couchbase.com/maven2/dev/" }

    google()
    mavenCentral()
}

dependencies {
    // ...
    
    implementation "com.couchbase.lite:couchbase-lite-android-ee:3.1.6"
    
    // ...
}

aars aren’t just compressed jars. So extracting the jar isn’t always the best option

If you are downloading the aar manually and adding to your project I found that newer version of android studio UI doesn’t have an option to automatically link aar (at least not on my linux box)

The method I found worked (which might not be the best method but I think it is ok) is the following:

I’m assuming you have already added the react native module via yarn and npm install and it will be under ./node_modules/react-native-cblite

In project ./android instead of a libs folder add couchbase-lite-android-ee-3.1.6 then add the aar file in there. add a build.gradle file in there and add the following

configurations.maybeCreate("default")
artifacts.add("default", file('couchbase-lite-android-ee-3.1.6.aar'))

You don’t need to modify ./andorid/build.gradle. In ./andorid/settings.gradle add include(":couchbase-lite-android-ee-3.1.6")

In ./andorid/app/build.gradle add implementation files('couchbase-lite-android-3.1.6') at the end of dependencies block

Then in ./node_modules/react-native-cblite/android/build.gradle add implementation project(":couchbase-lite-android-ee-3.1.6") at the end of dependencies block

You will need to reinstall completely to upgrade the module so I don’t consider this a big deal.

Hi Blake, really appreciate all the info. I am trying to understand if all these configurations are to be done inside ./node_modules/react-native-cblite or my project level.

I see in the very last step you specifically refer to react-native-cblite, so I believe the previous references to build.gradle and settings.gradle refer to my project level (i.e. /code/AwesomeProjectCBLite/android).

Hey @cammic … Sorry for the delay!

I don’t have much experience with React, so I’m probably not going to be a lot of help here. I think it is @x00 that refers to react-native-cblite, not me.

The standard location for the declaration of repositories (the gradle “repositories” clause) did move from the build.gradle file to the setting.gradle file, recently. No matter how you got your project started, there will be a repositories clause in one of those files. You simply need to find it and add the couchbase mave server to it, wherever it is.

One of your build.gradle files will have a “dependencies” clause. I’m going to guess that this will be in /code/AwesomeProjectCBLite/android. Wherever it is, just add that one implementation dependency.

All this manual downloading and hacking on the build system seems excessive, to me. It is what gradle is built to do. It should be a matter of adding those two lines I posted above. I think you’ll be much happier if you figure out how to get that to work than if you cobble together some other scheme.