Search Results for

    Show / Hide Table of Contents

    Start an Android Project

    To start a LiveSwitch Android project, do the following:

    1. Create a new Android Studio project.

    2. In the app folder, create a libs folder.

    3. Add the following jar files to your project to provide your app with the minimum set of Opus and VPX capabilities:

      • fm.liveswitch.jar
      • fm.liveswitch.opus.jar
      • fm.liveswitch.vpx.jar
      • fm.liveswitch.yuv.jar
    4. To enable H.264 support for your app, add fm.liveswitch.openh264.jar to the libs folder.

    5. To capture audio and video data from the user, add fm.liveswitch.android.jar to the libs folder.

    6. Add architecture-specific native libraries to your Android project's app/src/main folder. These libraries are in the Android/Libraries/jniLibs/arm64-v8a, Android/Libraries/jniLibs/armebi-v7a and Android/Libraries/jniLibs/x86 folders. Do the following:

      • If you are using fm.liveswitch.audioprocessing.jar, add libaudioprocessingfmJNI.so.
      • If you are using fm.liveswitch.openh264.jar, add libopenh264fmJNI.so.
      • If you are using fm.liveswitch.opus.jar, add libopusfmJNI.so.
      • If you are using fm.liveswitch.vpx.jar, add libvpxfmJNI.so.
      • If you are using fm.liveswitch.yuv.jar, add libyuvfmJNI.so.
      Tip

      If you want to be safe, add the entire jniLibs folder into your project directory. This ensures that you have the correct native libraries for any app.

    7. In your project non-source files, open app/build.gradle.

    8. In app/build.gradle, add the following to the end of the android block:

      packagingOptions {
                  exclude 'lib/linux_armv7/*'
                  exclude 'lib/linux_armv8/*'
                  exclude 'lib/linux_arm64/*'
                  exclude 'lib/linux_x64/*'
                  exclude 'lib/linux_x86/*'
                  exclude '**/libaudioprocessingfm.so'
                  exclude '**/libopenh264fm.so'
                  exclude '**/libopusfm.so'
                  exclude '**/libvpxfm.so'
                  exclude '**/libyuvfm.so'
              }
      sourceSets {
                  main {
                          jniLibs {
                              srcDirs = [
                                      'src/main/jniLibs'
                              ]
                          }
                  }
              }
      lintOptions {
                  abortOnError false
              }
      
    9. In app/build.gradle, add the following to the dependencies block:

      implementation fileTree(include: ['*.jar'], dir: '../lib')
      
    10. Resync your Gradle project.

    Work With ProGuard

    If you are using ProGuard, you must specify some additional configuration settings so that ProGuard correctly shrinks your code. ProGuard is a code-shrinking tool that is available in Android SDK Tools 25.0.10 or newer. In your ProGuard configuration file, add the following rules:

    -keep public class fm.liveswitch.audioprocessing.** { *; }
    -keep public class fm.liveswitch.openh264.** { *; }
    -keep public class fm.liveswitch.opus.** { *; }
    -keep public class fm.liveswitch.vpx.** { *; }
    -keep public class fm.liveswitch.yuv.** { *; }
    

    If you are using ProGuard and your app calls a method from the Java Native Interface (that is, it uses any of the native libraries noted above), then you cannot minify your APK builds as ProGuard incorrectly removes this code.

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    

    Disable Instant Run

    You should disable Instant Run in Android Studio.

    When Instant Run is enabled in Android Studio, it might result in severe audio and video performance problems on some development machines. For more information, see https://stackoverflow.com/questions/35168753/instant-run-in-android-studio-2-0-how-to-turn-off

    Permissions

    You must add the following permissions to your manifest:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <!-- largeHeap is necessary to avoid OOM errors on older devices -->
    <application android:label="..." android:theme="..." android:name="android.support.multidex.MultiDexApplication" android:largeHeap="true"></application>
    
    In This Article
    Back to top Copyright © LiveSwitch Inc. All Rights Reserved.Documentation for LiveSwitch Version 1.24.6