dji-sdk / Mobile-SDK-Android-V5

MSDK V5 Sample
Other
271 stars 145 forks source link

SDKManager.getInstance().init() Fails #161

Closed PeimanAtaei closed 1 year ago

PeimanAtaei commented 1 year ago

Hi

I want to start developing with the new MSDK v5 and I started with creating the app with a simple function to register the app.

I exactly followed this tutorial: https://developer.dji.com/doc/mobile-sdk-tutorial/en/quick-start/user-project-caution.html

and created a simple function to init the SDKManager but I face with this error :

FATAL EXCEPTION: DJIExecutor IO #1 Process: com.jpdroni.v5registration, PID: 31077 java.lang.UnsatisfiedLinkError: dlopen failed: library "libconstants.so" not found

I have the same error when run the official sample project: https://github.com/dji-sdk/Mobile-SDK-Android-V5/issues/160#issuecomment-1730998804

here is my main activity :

class MainActivity : AppCompatActivity() {

companion object{
    private const val TAG = "MainActivity"
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    registerApp()

}

private fun registerApp()
{
    SDKManager.getInstance().init(applicationContext,object : SDKManagerCallback{
        override fun onRegisterSuccess() {
            Log.i(TAG, "onRegisterSuccess")
        }

        override fun onRegisterFailure(error: IDJIError?) {
            Log.i(TAG, "onRegisterFailure")
        }

        override fun onProductDisconnect(productId: Int) {
            Log.i(TAG, "onProductDisconnect")
        }

        override fun onProductConnect(productId: Int) {
            Log.i(TAG, "onProductConnect")
        }

        override fun onProductChanged(productId: Int) {
            Log.i(TAG, "onProductChanged")
        }

        override fun onInitProcess(event: DJISDKInitEvent?, totalProcess: Int) {
            Log.i(TAG, "onInitProcess: ${event?.name}")
        }

        override fun onDatabaseDownloadProgress(current: Long, total: Long) {
            Log.i(TAG, "onDatabaseDownloadProgress")
        }

    })
}

}

PeimanAtaei commented 1 year ago

and this is my gradle file which is completely similar to the official sample :

plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' }

android { namespace 'com.jpdroni.v5registration' compileSdk 34

defaultConfig {
    applicationId "com.jpdroni.v5registration"
    minSdk 24
    targetSdk 34
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    ndk {
        abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
    }

}

packagingOptions {
    pickFirst 'lib/arm64-v8a/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
    jvmTarget = '17'
}
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
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 'com.mapbox.maps:android:10.9.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:6.13.0'
implementation("com.google.android.gms:play-services-location:21.0.1")
implementation 'androidx.core:core-ktx:+'

implementation 'com.google.android.gms:play-services-location:21.0.1'

implementation 'com.dji:dji-sdk-v5-aircraft:5.6.0'
compileOnly 'com.dji:dji-sdk-v5-aircraft-provided:5.6.0'
runtimeOnly 'com.dji:dji-sdk-v5-networkImp:5.6.0'

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

}

Please help me solve the problem

PeimanAtaei commented 1 year ago

I found the problem

I was testing the app with my tablet and I had that error. when I tried to run it on the RC of Mavic 3 I ran it successfully without crash

dji-dev commented 1 year ago

Agent comment from yating.liao in Zendesk ticket #91572:

I hope you're doing well. Could you please let us know the architecture of the tablet you are using? Currently, the SDK only supports 'arm64-v8a'.

°°°