大疆demo

一 到大疆的官网上去下载源码
https://developer.dji.com/cn/mobile-sdk/documentation/quick-start/index.html

image.png

源码取下来后,里面有一个 Sample Code 文件夹


image.png

把这个考出来, 这儿我们重命名DJSampleCode

,先不忙用android studio 打开.
要先改一下如下配置:

image.png
image.png

说明:'com.android.tools.build:gradle:7.2.2' 这个地方 要根据你的android studio 支持的版本来,如果设高了,它会提示你最高支持的版本号.

修改完后如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.5.10'
    ext.androidXCore = "1.6.0"
    repositories {
        //google()
        //mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/public' }   // new
        maven { url 'https://maven.aliyun.com/repository/google' }    // new
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }   // new
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        //google()
        //mavenCentral()

        maven { url 'https://maven.aliyun.com/repository/public' }   // new
        maven { url 'https://maven.aliyun.com/repository/google' }    // new
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }   // new
    }
}

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

app文件夹里面的这个文件也要改下


image.png
image.png

修改完后的文件内容如下:

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

repositories {
    //mavenLocal()
    maven { url 'https://maven.aliyun.com/repository/public' }   // new
    maven { url 'https://maven.aliyun.com/repository/google' }    // new
    maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }   // new
}

android {
    compileSdk 33
    buildToolsVersion '33.0.0'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.dji.sdk.sample"
        minSdkVersion 23
        targetSdkVersion 33
        multiDexEnabled true
        versionCode 1
        ndk {
            // On x86 devices that run Android API 23 or above, if the application is targeted with API 23 or
            // above, FFmpeg lib might lead to runtime crashes or warnings.
            abiFilters 'armeabi-v7a', 'arm64-v8a'
        }
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            shrinkResources false
            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"
        exclude 'META-INF/rxjava.properties'
        exclude 'assets/location_map_gps_locked.png'
        exclude 'assets/location_map_gps_3d.png'
    }

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

dependencies {
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.squareup:otto:1.3.8'
    implementation('com.dji:dji-sdk:4.16.4', {
        /**
         * Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
         * Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
         * is called.
         * Both will greatly reducing the size of the APK.
         */
        exclude module: 'library-anti-distortion'
        //exclude module: 'fly-safe-database'
    })
    compileOnly 'com.dji:dji-sdk-provided:4.16.4'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.core:core:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'com.jakewharton:butterknife:10.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
    implementation "androidx.core:core-ktx:1.6.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0-rc01"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
    implementation 'com.google.android.gms:play-services:11.8.0'

    implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"

    implementation 'com.google.guava:guava:29.0-android'
    implementation 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
}

然后再打开项目,这时候会自动 同步 项目. 把它停掉.

image.png
image.png
image.png

点保存后 , 它会自动同步项目了.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容