This step takes how to create a new project as an example. If it is integrated into an existing project, you can ignore this step.
Open Android Studio
and select the menu File
> New
> New Project
.
Select the project type Empty Activity
.
Select the project storage path.
Click Finish
to complete the new project creation.
ZegoDocsView SDK is built on AndroidX, so the imported project also needs to be built on AndroidX. If the developer’s project does not meet this requirement, please refer to Migrating to AndroidX for migration.
Unzip the downloaded zegodocsview_android.zip
file to get zegodocsview.aar
and copy it to your project directory libs/ folder.
Add the following code under the dependencies
node in the app/build.gradle
file:
implementation fileTree(include: ['*.jar','*.aar'], dir:'libs')
The SDK depends on the following modules. Add the following code under the dependencies
node in the app/build.gradle
file:
// recyclerview
implementation "androidx.recyclerview:recyclerview:1.1.0" //The current latest version is 1.1.0
// SDK is developed using kotlin, if it is a pure java project, you need to add this dependency
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.21" //The latest version at the time of writing is 1.4.21
// Only ZegoDocsView SDK 1.16 version needs to add this dependency
implementation "androidx.webkit:webkit:1.4.0" //The latest version is 1.4.0
Add a permission statement, open the app/AndroidManifest.xml
file, and add the following content:
<!-- Required permissions for SDK -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
As Android 6.0 requires dynamic application of permissions on some of the more important permissions, you cannot just declare permissions through the AndroidMainfest.xml
file. Therefore, you need to refer to and execute the following code (requestPermissions is a method of Activity).
String[] permissionNeeded = {
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED) {
requestPermissions(permissionNeeded, 101);
}
}
Permission description form:
Permission | Necessity | Permission Description | Reason |
---|---|---|---|
INTERNET | Necessary permissions | Access to network permissions | The basic functions of the SDK can only be used when connected to the Internet |
WRITE_EXTERNAL_STORAGE | Necessary permissions | Built-in SDK write permissions | SDK will save logs and related configuration files in the built-in SDK |
READ_EXTERNAL_STORAGE | Necessary permissions | Built-in SDK read permissions | SDK needs to upload local files |
Prevent code confusion
In the proguard-rules.pro file, add the configuration of the -keep class to the SDK, so as to prevent the SDK public class names from being confused:
-keep class im.zego.zegodocs.**{*;}