Importing the SDK
Using Gradle in Android Studio, you can easily add RC's Instant Messaging library (IMLib) as a dependency to your build.
You can either import remote dependencies directly via Gradle or import local dependencies as an Android native library module.
Environment Requirements
- (SDK ≧ 5.6.3) Requires Android 5.0 (API 21) or higher
- (SDK < 5.6.3) Requires Android 4.4 (API 19) or higher
Checking Versions
Before importing the SDK, you can check RC's Maven repository to confirm the latest version number.
Gradle
Use Gradle to add RC's Instant Messaging library (IMLib) as a remote dependency. Note that you need to use RC's Maven repository. The configuration in Android Studio differs for Gradle plugin versions below 7.0, version 7.0, and versions 7.1 and above. Configure according to your current Gradle plugin version. This article uses Gradle plugin versions below 7.0 as an example.
-
Declare RC's Maven repository. Using Gradle plugin versions below 7.0 as an example, open the
build.gradlefile in the root directory (under Project view):allprojects {
repositories {
...
// RC Maven repository URL
maven {url "https://maven.rongcloud.cn/repository/maven-releases/"}
}
}If using Gradle plugin version 8.0 or higher, it is recommended to configure it in the
settings.gradlefile in the root directory.dependencyResolutionManagement {
repositories {
...
// RC Maven repository URL
maven {url "https://maven.rongcloud.cn/repository/maven-releases/"}
}
} -
In your app's
build.gradle, add RC's Instant Messaging library (IMLib) as a remote dependency.dependencies {
...
// Example of integrating IMLib
api 'cn.rongcloud.sdk:im_lib:x.y.z'
}tipThe latest version numbers for each SDK may differ and could be in the format x.y.z.h. Check RC's Maven repository for details.
Android Native Library (Module)
Before importing the SDK, you need to obtain the SDK source code from GitHub or Gitee.
-
Open your project in Android Studio, then click File > New > Import Module, locate the downloaded Module component, and import it.
-
If the imported content includes a plugin's aar package, move it to the
app/libsdirectory. -
Open the
settings.gradlefile in the root directory (under Project view) and add the IMLib native library module.include ':IMLib'
... -
In your app's
build.gradle, add IMLib as a native library module dependency.dependencies {
...
api project(':IMLib')
...
} -
(Optional) When importing the SDK as an Android native library module, Javadoc is not included by default. It is recommended to download Javadoc from RC's Maven repository and import it separately to enable instant viewing in Android Studio.
For guidance, refer to the following knowledge base link: