Android
Using Liblinphone
Requirements
Fisrt of all, install the Android SDK from the official site. Then run the android binary and install the following:
- Android SDK Tools
- Android SDK Platform-tools
- Android SDK Build-tools
- An Android SDK platform
Please take an eye on the README and ChangeLog files from the git repo in order to make sure to have always up to date information about the project. Note that the README provide detailed instructions to compile the linphone app and liblinphone SDK, which is not required to simply use the SDK in your own app.
Create your project
Create a directory for your new project, then, create your project. You can either use the assistant from your IDE (Eclipse or Android Studio), or the command line:
If you do create your project using the command line, you can still import it in your IDE.
For Eclipse , go to File -> Import -> Android - Existing Android Code Into Workspace.
Importing liblinphone SDK
Two options are available. The first one is to configure our maven repository in your build.gradle file and add our SDK dependency. The second one is to manually download and install our SDK.
Use our maven repository
Edit your top level gradle build file and edit the allprojects' repositories list to add our own:
maven {
url "http://linphone.org/snapshots/maven_repository/"
}
// For releases
maven {
url "http://linphone.org/releases/maven_repository/"
}
Then in your app's gradle build file add the either one of the following to your dependencies list:
debugImplementation 'org.linphone:liblinphone-sdk:4.0.1-DEBUG'
Before 4.0.1 there is only a release implementation available !
Changes starting with 4.1:
- The artifact id is now linphone-android-sdk instead of liblinphone-sdk.
- A no-video build is available with the group id org.linphone.no-video instead of org.linphone.
- The javadoc is also available with the release AAR
Here's a sample on how to the latest 4.1 snapshot:
releaseImplementation "org.linphone:linphone-sdk-android:4.1+"
Download our SDK
You can download a zip with the latest linphone SDK for Android.
If you don't plan on doing any video, you can use a smaller SDK.
Unzip it in the root folder of your project (next to the AndroidManifest.xml file).
Your project might already contain a libs directory, in that case, just merge the two of them.
To configure your project, putting the aar in the libs/ directory should be enough.
In your build.gradle add in repositories:
...
flatDir { dirs 'libs' }
}
If for some reason it's not (for example if you decided to put the aar in another folder), just add the folder to flatDir.
And in dependencies:
...
//compile(name:'liblinphone-sdk-release', ext:'aar') This was the old way and still works but you'll have a warning
implementation 'org.linphone.core:liblinphone-sdk-release@aar'
}
And now you have liblinphone sdk integrated in your project.
You can try your setup by trying to start a sample Core:
// You must provide the Android app context as createCore last param !
Core core = Factory.instance().createCore(null, null, this);
core.start();
Using liblinphone API
The cross platform reference API documentation is browsable here.
You can also download the source code of Linphone Android (see the Source Code part of this page) and take a look either at the LinphoneMini project in the sample/ folder or at the tutorials in the submodules/linphone/coreapi/help/java/org/linphone/core/tutorials/ folder.
Compile your app and run
Nothing specific to do, just compile it as a normal Android application (on Eclipse, right click on the project -> Run as -> Android Application).
Native debugging
You can natively debug Linphone-android with ndk-gdb. You must compile Linphone in debug mode:
To attempt this you must had a folder in your root project nommed "JNI" with two file:
- An empty file Android.mk
- And Application.mk
On root project, run:
When it's running you must load debug libraries (Replace PROJECT_ROOT and ABI on your convenience):
Troubleshooting
Activate debug traces with setDebugMode(boolean, string);
To get debug traces from adb:
adb logcat
To get symbolicated stack trace from adb, use:
adb logcat -d | ndk-stack -sym ./libs-debug/`adb shell getprop ro.product.cpu.abi | tr -d '\r'`