- Android SDK 28+
- Android Studio
- Kotlin
We use Kotlin and AndroidX in the native module.
Android Studio -> Refactor -> Migrate to AndroidX... -> Migrate
Use react-native link
to add the library to your project:
react-native link react-native-agora
Define the react-native-agora
project in android/settings.gradle
:
...
include ':react-native-agora'
project(':react-native-agora').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-agora/android')
Add the react-native-agora
as a dependency of your app in android/app/build.gradle
:
...
dependencies {
...
implementation project(':react-native-agora')
}
Add import io.agora.rtc.react.RCTAgoraRtcPackage;
and new RCTAgoraRtcPackage()
in your MainApplication.java
:
import io.agora.rtc.react.RCTAgoraRtcPackage;
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTAgoraRtcPackage()
);
}
If you've defined project-wide properties in your root build.gradle
, this library will detect the presence of the following properties:
buildscript {...}
allprojects {...}
/**
* Project-wide Gradle configuration properties
*/
ext {
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
minSdkVersion = 16
targetSdkVersion = 28
kotlin_version = "1.3.72"
}
or do
buildscript {
ext {
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
minSdkVersion = 16
targetSdkVersion = 28
kotlin_version = "1.3.72"
}
}
...
Add android:networkSecurityConfig
to your manifest file (android/app/src/main/AndroidManifest.xml
):
<application android:networkSecurityConfig="@xml/network_security_config">
...
</application>