dji-sdk / Mobile-SDK-Android-V5

MSDK V5 Sample
Other
288 stars 146 forks source link

MRTCController Couldn't load lib #54

Closed zofnk closed 1 year ago

zofnk commented 2 years ago

我按文档要求一步步集成了sdk 但是在推流RTMP和AGORA的时候发现失败

ErrorImp{errorType='LIVESTREAM', errorCode='UNKNOWN', innerCode='null', description='未知直播错误', hint='Live Stream error is unknown'}

然后以为是surfaceview的问题,并单独创建了一个,也集成了

if (videoDecoder == null) {
            videoDecoder = VideoDecoder(
                this,
                LiveStreamManager.getInstance().videoChannelType,
                DecoderOutputMode.SURFACE_MODE,
                mDatabind.liveStreamSurfaceView.holder,
                -1,
                -1,
                true
            )
        } else if (videoDecoder?.decoderStatus == DecoderState.PAUSED) {
            videoDecoder?.onResume()
        }

但是还是失败,日志中

MRTCController - Couldn't load lib
LOG_JNI - [MRTC-E mrtc_core_init:   93]: : mrtc_core_init file path: /data/app/~~aFa4X5Y21O_pb1sOZU6olQ==/com.ws.packagename-2QtZ4euC7N9DGrMgDbWSTw==/lib/arm64

LOG_JNI - [MRTC-E find_dl_handle_node_by_prot_name:   70]: : can't find dl_node by prot_name dji,agora
LOG_JNI - [MRTC-E mrtc_agent_init:  190]: : can't find dl_handle_node in lib handle list
MRTCLiveShare - init agent error,code = 420478983
MRTCLiveShare - initMrtcAgent error,code = 420478983

这两个code = 420478983无从查起,不知道是啥意思

然后发现在apk中是有so库的,但是在/data/app/packagename-1/lib下并没有写入任何的so库文件,是不是因此导致Couldn't load lib? 在sample中是可以的,并且新开了一个项目(有且只有依赖了库,项目逻辑代码只有如下,也并没有surface的创建,虽然知道并不会成功,只是想看看是否能完成so的加载),居然也可以。

TestProject:


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        SDKManager.getInstance().init(this, object : SDKManagerCallback {
            override fun onRegisterSuccess() {}
            override fun onRegisterFailure(error: IDJIError?) {}
            override fun onProductDisconnect(product: Int) {}
            override fun onProductConnect(product: Int) {}
            override fun onProductChanged(product: Int) {}
            override fun onInitProcess(event: DJISDKInitEvent?, totalProcess: Int) {}
            override fun onDatabaseDownloadProgress(current: Long, total: Long) {}
        })

        findViewById<Button>(R.id.btn).setOnClickListener{
           val settings =  LiveStreamSettings.Builder()
                .setLiveStreamType(LiveStreamType.AGORA)
                .setAgoraSettings(AgoraSettings.Builder()
                    .setChannelId("test")
                    .setToken("really token from Agora")
                    .setUid("50000")
                    .setEnableSafety(false)
                    .build()).build()
            LiveStreamManager.getInstance().liveStreamSettings = settings
            LiveStreamManager.getInstance().startStream(object : CommonCallbacks.CompletionCallback{
                override fun onSuccess() {
                    Log.e("apex","stream ok")
                }
                override fun onFailure(error: IDJIError) {
                    Log.e("apex","stream failed :${error.description()}")
                }
            })
        }

    }
}
class App : Application(){
    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        com.secneo.sdk.Helper.install(this)
    }
}

这个问题倒腾了两三天了,希望务必能帮忙看一下!

DJI-William commented 2 years ago
  1. 你现在确认同样的Agora Settings在Sample上是OK的对吧。
  2. MSDK v5.1的直播库是直接运行.so的,这些添加了嘛? doNotStrip "//libmrtc_28181.so" doNotStrip "//libmrtc_agora.so" doNotStrip "//libmrtc_core.so" doNotStrip "//libmrtc_core_jni.so" doNotStrip "//libmrtc_data.so" doNotStrip "//libmrtc_log.so" doNotStrip "//libmrtc_onvif.so" doNotStrip "//libmrtc_rtmp.so" doNotStrip "//libmrtc_rtsp.so"
zofnk commented 2 years ago
  1. 你现在确认同样的Agora Settings在Sample上是OK的对吧。
  2. MSDK v5.1的直播库是直接运行.so的,这些添加了嘛? doNotStrip "//libmrtc28181.so" doNotStrip "/_/libmrtcagora.so" doNotStrip "/_/libmrtccore.so" doNotStrip "/_/libmrtc_corejni.so" doNotStrip "/_/libmrtcdata.so" doNotStrip "/_/libmrtclog.so" doNotStrip "/_/libmrtconvif.so" doNotStrip "/_/libmrtcrtmp.so" doNotStrip "/_/libmrtc_rtsp.so"

有添加,是有带号``` doNotStrip "/*/libmrtc_28181.so" ```

DJI-William commented 2 years ago

你在当前页面是不是没有显示视频流?我暂时看不出问题在哪。

zofnk commented 2 years ago

不是,是设备的安装目录下连so都没有

DJI-William commented 2 years ago

说明你引入so的方法有误,能把你的build.gradle文件发过来吗?

zofnk commented 2 years ago

app module -->

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdk Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION)

    defaultConfig {
        applicationId project.ANDROID_APPLICATION_ID
        minSdk Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
        targetSdk Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"
        manifestPlaceholders["API_KEY"] = project.AIRCRAFT_API_KEY
        multiDexEnabled true

        ndk {
            abiFilters 'arm64-v8a'
        }
    }
    signingConfigs {
        release {
            storeFile file('mKey.jks')  //路径
            storePassword '89925977'
            keyAlias 'pan'
            keyPassword '89925977'
            v2SigningEnabled true
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')/*, '../../JDYAir_V5/proguard-relative/sample.pro'*/
            signingConfig signingConfigs.release
        }
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')/*, '../../JDYAir_V5/proguard-relative/sample.pro'*/
            signingConfig signingConfigs.release
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }
    buildFeatures {
        dataBinding true
        viewBinding true
    }
    flavorDimensions "defaultDimension"
    productFlavors {
        JA {
            manifestPlaceholders = [CHANNEL_VALUE: "JA", APP_NAME: "@string/app_name"]
        }
        BA {
            manifestPlaceholders = [CHANNEL_VALUE: "BA", APP_NAME: "@string/app_name_ba"]
        }
    }
    //关闭lint
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    packagingOptions {
        doNotStrip "*/*/libconstants.so"
        doNotStrip "*/*/libdji_innertools.so"
        doNotStrip "*/*/libdjibase.so"
        doNotStrip "*/*/libDJICSDKCommon.so"
        doNotStrip "*/*/libDJIFlySafeCore-CSDK.so"
        doNotStrip "*/*/libdjifs_jni-CSDK.so"
        doNotStrip "*/*/libDJIRegister.so"
        doNotStrip "*/*/libdjisdk_jni.so"
        doNotStrip "*/*/libDJIUpgradeCore.so"
        doNotStrip "*/*/libDJIUpgradeJNI.so"
        doNotStrip "*/*/libDJIWaypointV2Core-CSDK.so"
        doNotStrip "*/*/libdjiwpv2-CSDK.so"
        doNotStrip "*/*/libffmpeg.so"
        doNotStrip "*/*/libFlightRecordEngine.so"
        doNotStrip "*/*/libvideo-framing.so"
        doNotStrip "*/*/libwaes.so"
        doNotStrip "*/*/libagora-rtsa-sdk.so"
        doNotStrip "*/*/libc++.so"
        doNotStrip "*/*/libc++_shared.so"
        doNotStrip "*/*/libmrtc_28181.so"
        doNotStrip "*/*/libmrtc_agora.so"
        doNotStrip "*/*/libmrtc_core.so"
        doNotStrip "*/*/libmrtc_core_jni.so"
        doNotStrip "*/*/libmrtc_data.so"
        doNotStrip "*/*/libmrtc_log.so"
        doNotStrip "*/*/libmrtc_onvif.so"
        doNotStrip "*/*/libmrtc_rtmp.so"
        doNotStrip "*/*/libmrtc_rtsp.so"
    }
}

dependencies {
    implementation project(':uxsdk')

    implementation deps.legacySupport
    implementation deps.lifecycleViewModel
    implementation deps.lifecycleLiveData
    implementation deps.ktxCore
    implementation deps.appcompat
    implementation deps.material
    implementation deps.constraintLayout

    implementation deps.JetpackMvvm
    implementation deps.MDialogLifecycle
    implementation deps.MDialogCore
    implementation deps.MDialogColor
    implementation deps.MDialogDatetime
    implementation deps.MDialogBottomsheets

    implementation deps.utilcodex

    implementation deps.okhttp3//网络库的依赖项
    implementation deps.retrofit//Retrofit网络请求框架
    implementation deps.immersionbar
    implementation deps.immersionbarKtx
    implementation deps.MPAndroidChart
    implementation deps.rangeSeekbar
    implementation deps.swiperefreshlayout
    implementation deps.otherRecyclerview
    implementation deps.adapterHelper

    implementation deps.circleimageview //圆角图片
    implementation deps.popmenu//弹出菜单按钮
    implementation deps.matisse//图片选择
    implementation deps.glide//图片加载
    implementation deps.switch//开关按钮
    implementation deps.progressmanager//OKhttp 进度显示库
    implementation deps.taggroup
    implementation deps.citypickerview
    implementation deps.kprogresshud
    implementation deps.eventbus

    implementation deps.service
    implementation deps.mqttv3

    implementation deps.easypermissions
    implementation deps.litepal//数据库
    implementation(deps.picker) { exclude group: 'com.android.support' }

    implementation deps.koin_android
    implementation deps.koin_compat

    implementation deps.aircraft
    compileOnly deps.aircraftProvided
    implementation deps.networkImp

}

project-->

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: rootProject.file('dependencies.gradle')

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        classpath 'com.github.kezong:fat-aar:1.3.6'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
        classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1.1'
        classpath "org.jacoco:org.jacoco.core:0.8.7"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url JITPACK_MAVEN }
        maven { url REPO_MAVEN2 }
        maven { url SAFEROOM_MAVEN }
        maven { url KOTLIN_MAVEN }
        repositories {
            flatDir {
                dirs new File(rootProject.projectDir.getAbsolutePath() + '/libs')
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

uxsdk module -->

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION)

    resourcePrefix "uxsdk_"
    defaultConfig {
        minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions{
        jvmTarget = JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation deps.annotation
    implementation deps.appcompat
    implementation deps.multidex
    implementation deps.legacySupport
    implementation deps.recyclerview
    implementation deps.okio
    implementation deps.wire
    implementation deps.constraintLayout
    implementation deps.lifecycleJava8
    implementation deps.lifecycleRuntime
    implementation deps.lifecycleProcess
    implementation deps.media
    implementation deps.kotlinLib
    implementation deps.ktxCore
    implementation deps.rx3Android
    implementation deps.lottie
    implementation deps.cardview

    api deps.maplibreAnotation
    api deps.maplibreTurf
    api deps.maplibreSdk
    api deps.amap3DMap
    api deps.amapSearch

    api deps.playservicesplaces
    api deps.playservicesmaps
    api deps.playserviceslocation
    api deps.playservicesbase

    compileOnly deps.aircraftProvided
    compileOnly deps.aircraft

    api files("../libs/map/DJI-Mapkit-Amap.aar")
    api files("../libs/map/DJI-Mapkit-Core.aar")
    api files("../libs/map/DJI-Mapkit-Maplibre.aar")
    api files("../libs/map/DJI-Mapkit-Google.aar")
}
DJI-William commented 2 years ago

我不确定 doNotStrip "//libmrtc_agora.so"和doNotStrip "//libmrtc_agora.so"是否会造成区别,我暂时也找不到原因在哪。因为你能够在Sample上直播至少说明你的Agora设置是没问题的。我已经提单给研发将直播的直播错误码在细化一下。code = 420478983的意思是初始化失败,找不到so库。

DJI-William commented 1 year ago

@zofnk 经过排查,发现minSdkVersion改为21可以解决问题。

fail572872916 commented 8 months ago

我遇到了同样的错误,但我的minSdkVersion无法改为21

fail572872916 commented 8 months ago

我的配置如下 plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' // id 'kotlin-android-extensions' id 'com.google.devtools.ksp' id 'kotlin-parcelize'

}

android { namespace '' compileSdk 33

defaultConfig {
    applicationId ""
    minSdk 24
    targetSdk 30
    versionCode 1
    versionName "1.0"

    ndk {
        abiFilters 'arm64-v8a' // 当前 MSDK 只支持 arm64-v8a 架构
    }

    // MSDK 相关的 so 库,加上一下配置
    packagingOptions {
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    }

    // MSDK 相关的 so 库,加上一下配置
    packagingOptions {
        doNotStrip "*/*/libconstants.so"
        doNotStrip "*/*/libdji_innertools.so"
        doNotStrip "*/*/libdjibase.so"
        doNotStrip "*/*/libDJICSDKCommon.so"
        doNotStrip "*/*/libDJIFlySafeCore-CSDK.so"
        doNotStrip "*/*/libdjifs_jni-CSDK.so"
        doNotStrip "*/*/libDJIRegister.so"
        doNotStrip "*/*/libdjisdk_jni.so"
        doNotStrip "*/*/libDJIUpgradeCore.so"
        doNotStrip "*/*/libDJIUpgradeJNI.so"
        doNotStrip "*/*/libDJIWaypointV2Core-CSDK.so"
        doNotStrip "*/*/libdjiwpv2-CSDK.so"
        doNotStrip "*/*/libFlightRecordEngine.so"
        doNotStrip "*/*/libvideo-framing.so"
        doNotStrip "*/*/libwaes.so"
        doNotStrip "*/*/libagora-rtsa-sdk.so"
        doNotStrip "*/*/libc++.so"
        doNotStrip "*/*/libc++_shared.so"
        doNotStrip "*/*/libmrtc_28181.so"
        doNotStrip "*/*/libmrtc_agora.so"
        doNotStrip "*/*/libmrtc_core.so"
        doNotStrip "*/*/libmrtc_core_jni.so"
        doNotStrip "*/*/libmrtc_data.so"
        doNotStrip "*/*/libmrtc_log.so"
        doNotStrip "*/*/libmrtc_onvif.so"
        doNotStrip "*/*/libmrtc_rtmp.so"
        doNotStrip "*/*/libmrtc_rtsp.so"
    }
}
signingConfigs {
    def alias = ""
    def password = ""
    def filePath = '../app/oneMap.jks'

    debug {

        storeFile file(filePath)
        storePassword password
        keyAlias alias
        keyPassword password
    }
    release {

        storeFile file(filePath)
        storePassword password
        keyAlias alias
        keyPassword password
    }
}
buildFeatures {

    viewBinding = true
    dataBinding = true
}
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

} def room_version = "2.5.0" def rxhttp_version = "3.2.4" dependencies { compileOnly deps.aircraftProvided implementation deps.aircraft

/** <-----------------sample所需--------------------> **/
implementation project(':android-sdk-v5-uxsdk')
implementation deps.appcompat
implementation deps.constraintLayout
implementation deps.aacCommon
implementation deps.aacRuntime
implementation deps.kotlinLib
implementation deps.ktxCore
implementation deps.ktxFrag
implementation deps.ktxNavigation
implementation deps.ktxNavigationUi
implementation deps.recyclerview
implementation deps.legacySupport
implementation deps.lifecycleViewModel
implementation deps.lifecycleLiveData
implementation deps.leakcanary
implementation deps.glide
implementation deps.dynamicanimation
implementation deps.expandedit
implementation deps.rx3Kt
implementation deps.dom
ksp deps.glidecompiler

implementation(project(":basemattermap"))
implementation(project(":switchButton"))
implementation(project(":xpopup"))
implementation(project(":basefly"))
implementation(project(":TabLayout"))
implementation(project(":lib_circularavatar"))
implementation(project(":MapGeoJson"))
implementation("com.blankj:utilcodex:1.31.1")

implementation("com.afollestad.material-dialogs:core:3.3.0")
implementation("com.afollestad.material-dialogs:input:3.3.0")
implementation("com.afollestad.material-dialogs:files:3.3.0")
implementation("com.afollestad.material-dialogs:lifecycle:3.3.0")

// 权限请求框架:https://github.com/getActivity/XXPermissions
api("com.github.getActivity:XXPermissions:18.5")

api("io.github.jeremyliao:live-event-bus-x:1.8.0")
implementation("io.coil-kt:coil:2.4.0")

implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
// To use Kotlin Symbol Processing (KSP)
ksp("androidx.room:room-compiler:$room_version")
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.14"

//MQTT需要使用到Paho Android Service库
implementation ("org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0")
implementation ("org.eclipse.paho:org.eclipse.paho.android.service:1.1.1")

//lottie动画
implementation "com.airbnb.android:lottie:5.2.0"

implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"
// ksp/kapt/annotationProcessor choose one
ksp "com.github.liujingxing.rxhttp:rxhttp-compiler:$rxhttp_version"
implementation 'org.xutils:xutils:3.9.0'

implementation("io.coil-kt:coil:2.4.0")
implementation("com.github.BzCoder:EasyGlide:2.0.1")

implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation 'com.github.liujingxing.rxlife:rxlife-rxjava3:2.2.2' //RxJava3, Automatic close request

// implementation 'com.squareup.okhttp3:okhttp:4.12.0' // implementation ("com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version") // ksp/kapt/annotationProcessor choose one // kapt ("com.github.liujingxing.rxhttp:rxhttp-compiler:$rxhttp_version")