dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
972 stars 579 forks source link

Migrating Java 1.8 version to Java 17 #1258

Closed FawadAbbas12 closed 7 months ago

FawadAbbas12 commented 7 months ago

Hello your provided samples are all using java 8 so if i change my project's version to 17 will it work ?

Jai-GAY commented 7 months ago

ya can, can upgrade to Java 11 and further to 17 but a few changes. especially the Sample Code\app\src\main\java\com\dji\sdk\sample\demo\lidar\LidarView.kt

remove this //import kotlinx.android.synthetic.main.view_lidar.view.* gradle may have to upgrade higher Sample Code\build.gradle ext.kotlin_version = '1.8.21' and classpath 'com.android.tools.build:gradle:7.4.2' Sample Code\app\build.gradle sourceCompatibility JavaVersion.VERSION_11 and targetCompatibility JavaVersion.VERSION_11 may need to remove this //apply plugin: 'kotlin-android-extensions'

FawadAbbas12 commented 7 months ago

ya can, can upgrade to Java 11 and further to 17 but a few changes. especially the Sample Code\app\src\main\java\com\dji\sdk\sample\demo\lidar\LidarView.kt remove this //import kotlinx.android.synthetic.main.view_lidar.view.* gradle may have to upgrade higher Sample Code\build.gradle ext.kotlin_version = '1.8.21' and classpath 'com.android.tools.build:gradle:7.4.2' Sample Code\app\build.gradle sourceCompatibility JavaVersion.VERSION_11 and targetCompatibility JavaVersion.VERSION_11 may need to remove this //apply plugin: 'kotlin-android-extensions'

Thanks for heads-up i am following same process

FawadAbbas12 commented 7 months ago

Thanks @Jai-GAY for providing help i have successfully ported this project to java17

here is app:build.gradle file in-case anyone need it in future


apply plugin: 'com.android.application'

repositories {
    mavenLocal()
    maven { url 'https://jitpack.io' }
}

android {
    namespace 'com.example.streaminigapp'
    compileSdk 34
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.example.streaminigapp"
        minSdk 31
        targetSdk 33
        versionCode 1
        versionName "1.0"
    }

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

    dexOptions {
        javaMaxHeapSize "4g"
    }

    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"
        doNotStrip "*/*/libDJISDKLOGJNI.so"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}

dependencies {
    /**
     * DJI Specific Libs
     */
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.squareup:otto:1.3.8'
    implementation('com.dji:dji-sdk:4.17', {
//        exclude module: 'library-anti-distortion'
        exclude module: 'fly-safe-database'
    })
    compileOnly 'com.dji:dji-sdk-provided:4.17'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.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'
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.annotation:annotation:1.7.0'
    //<-------------------------- END DJI imports ----------------------------->

    /**
     * Root Encoder Libs
     */

    implementation 'com.github.pedroSG94.RootEncoder:library:2.3.1'

    //<-------------------------- END RootEncoder imports ----------------------------->

}