Sample app
- Download
Here we provide you with a sample application to experience ZEGOCLOUD's In-app Chat, and also describe how to run the sample code.
Prerequisites
- Android Studio 2.1 or later.
- Android SDK Packages: Android SDK 28, Android SDK Platform-Tools 28.x.x or later.
- An Android device or Simulator that is running on Android 4.1 or later and supports audio and video. We recommend you use a real device (Remember to enable the USB debugging).
- The Android device is connected to the internet.
- Contact the ZEGOCLOUD Technical support to get the AppID and ServerSecret for SDK integration.
- Get the token that SDK required for login authentication. For details, see Authentication.
- When you compile the sample code for the first time, if you do not have the corresponding dependent library or build tool, Android Studio will automatically download the sample code. This may take a while for you to wait.
- We recommend you download the specified
gradle
and required dependencies. To download, go to Gradle Services. Thegradle
we use in the sample code are as follows:- gradle: 4.6 (check it in the
project/gradle/wrapper/gradle-wrapper.properties
file). - gradle Android plug-in: 3.2.1 (check it in the
project/build.gradle
file).
- gradle: 4.6 (check it in the
Sample code structure
The following structure shows the subdirectory structure of the In-app Chat sample code:
.
├── app
│ ├── agconnect-services.json
│ ├── build
│ │ ├── generated
│ │ ├── intermediates
│ │ ├── outputs
│ │ └── tmp
│ ├── build.gradle
│ ├── libs
│ │ ├── MiPush_SDK_Client_4_9_1.jar
│ │ ├── VERSION.txt
│ │ ├── ZIM.jar
│ │ ├── arm64-v8a
│ │ ├── armeabi-v7a
│ │ ├── pushOpenClient_v3.0.0.4_484_81c1f83_release.jar
│ │ ├── x86
│ │ ├── x86_64
│ │ └── zpns-release.aar
│ ├── proguard-rules.pro
│ ├── src
│ │ └── main
│ └── zim_example_key.jks
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
Run the sample code
In Android Studio, click Open an Existing Project.
Open the
ZIMExampleJava
folder in the unzipped sample code package.Go to the SDK downloads to download the latest version of SDK, copy the unzipped SDK package file to the
app/libs
directory.Modify the
KeyCenter.java
file under theZIMExample/app/src/main/java/im/zego/zimexample
folder with the AppID and ServerSecret (remember to add a "L" after the AppID) that you get in the Prerequisites steps.Connect the Android device to your computer, after you enabled the developer mode and USB debugging on the device, the option box in the upper place of Android Studio changes like the following, which means you are ready to run the sample code on the Android device.
Before:
After:
<div class = 'mk-hint'>
- When you connect your PC to an Android device, a message will pop up on most devices. The message varies according to Android vendors. You can select USB mode according to the actual situation.
- After the Android device is connected to your computer, you will need to enable the **developer mode*8 and **USB debugging** on the device based on the actual situation. You can search for specific enabling methods by yourself.
</div>
- Click the Run button to run the sample code and experience the In-app Chat service.
FAQ
This error error: incompatible types: unexpected return value
occurs when Android Studio runs the sample code.
)
The AppID and ServerSecret in our sample code This is because there are no specific values for AppID and ServerSecret in the sample code you downloaded. Please follow the Prerequisites to get the AppID and ServerSecret first and try again.