dji-sdk / Mobile-UXSDK-Android

DJI Mobile UXSDK is a suite of product agnostic UI objects that fast tracks the development of Android applications using the DJI Mobile SDK.
Other
154 stars 109 forks source link

Support for Kotlin in the DJI-UX SDK #106

Closed india2sarthak closed 2 years ago

india2sarthak commented 4 years ago

I have been unable to use DJI UXSDK in a Kotlin app. I followed the steps mentioned in the UXSDK getting started document to include the dependencies. However, whenever I include any UI element of the ux-sdk in the layout xml file, the app just crashes with the following message: libbacktrace: bool ThreadEntry::Wait(int): pthread_cond_timedwait for value 1 failed: Connection timed out.

So does the UX SDK support kotlin as the primary language of the project or could it be due to some other reason? Here is my build gradle file

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

repositories {
    mavenLocal()
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "***"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "**"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        ndk {
            abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        doNotStrip "*/*/libdjivideo.so"
        doNotStrip "*/*/libSDKRelativeJNI.so"
        doNotStrip "*/*/libFlyForbid.so"
        doNotStrip "*/*/libduml_vision_bokeh.so"
        doNotStrip "*/*/libyuv2.so"
        doNotStrip "*/*/libGroudStation.so"
        doNotStrip "*/*/libFRCorkscrew.so"
        doNotStrip "*/*/libUpgradeVerify.so"
        doNotStrip "*/*/libFR.so"
        doNotStrip "*/*/libDJIFlySafeCore.so"
        doNotStrip "*/*/libdjifs_jni.so"
        doNotStrip "*/*/libsfjni.so"
        doNotStrip "*/*/libDJICommonJNI.so"
        doNotStrip "*/*/libDJICSDKCommon.so"
        doNotStrip "*/*/libDJIUpgradeCore.so"
        doNotStrip "*/*/libDJIUpgradeJNI.so"
        doNotStrip "*/*/libDJIWaypointV2Core.so"
        doNotStrip "*/*/libAMapSDK_MAP_v6_9_2.so"
        doNotStrip "*/*/libDJIMOP.so"
        exclude 'META-INF/rxjava.properties'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation ('com.dji:dji-sdk:4.13', {
        exclude module: 'library-anti-distortion'
        exclude module: 'fly-safe-database'
        exclude group: 'com.amap.api'
    })
    compileOnly ('com.dji:dji-sdk-provided:4.13')
    implementation 'com.dji:dji-uxsdk:4.13'
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation "com.squareup.okhttp3:okhttp:4.9.0"
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
    implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0') {
        exclude group: 'group_name', module: 'module_name'
    }
    implementation 'androidx.cardview:cardview:1.0.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
india2sarthak commented 4 years ago

Update: It had nothing to do with Kotlin being the primary language. Was able to fix the issue by downgrading the minSdkVersion to 22 (from 23). Not sure why that happened, I would recommend adding it to the getting started doc if it is indeed required to have the minSdkVersion set to less than 22.