dji-mobile-sdk-tutorials / android-importandactivatesdkinandroidstudio Goto Github PK
View Code? Open in Web Editor NEWThis demo teaches you how to import and activate DJI SDK in your Android Studio project.
License: MIT License
This demo teaches you how to import and activate DJI SDK in your Android Studio project.
License: MIT License
Hello,
I am just followed all the step in this tutorial https://developer.dji.com/mobile-sdk/documentation/application-development-workflow/workflow-integrate.html but I stuck at the part to build gradle after adding DJI module dependencies. This is my error, please help me !
Build gives the error:
Manifest merger failed : android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
I state that I am still trying to test it in the Android Studio emulator.
I load the code into the emulator, give all permissions and then the page closes with the message "registering, pls wait" and never gives the success message. (I have already entered the app key in the manifest)
Thanks in advance for any help.
Crash logs:
08-09 03:59:13.459 22370-22418/com.dji.importSDKDemo I/n: ConnectivityManager says we are online
08-09 03:59:13.471 22370-22486/com.dji.importSDKDemo D/Previewer.cpp: Previewer::setAuthValue()
08-09 03:59:13.472 22370-22486/com.dji.importSDKDemo D/Previewer.cpp: Previewer::setAuthValue()
**08-09 03:59:13.473 22370-22396/com.dji.importSDKDemo D/com.dji.importSDKDemo.MainActivity: The metadata received from server is invalid, please reconnect to the server and try.**
**08-09 03:59:13.474 22370-22396/com.dji.importSDKDemo E/TAG: The metadata received from server is invalid, please reconnect to the server and try.**
08-09 03:59:13.628 22370-22370/com.dji.importSDKDemo D/DJIRemoteVersionInfo: UpgradeConfigInfo getFile for net success
08-09 03:59:16.563 22370-22417/com.dji.importSDKDemo I/n: ConnectivityManager says we are online
08-09 03:59:19.586 22370-22418/com.dji.importSDKDemo I/n: ConnectivityManager says we are online
08-09 03:59:21.442 22370-22396/com.dji.importSDKDemo I/n: ConnectivityManager says we are online
Error:
08-09 03:59:13.473 22370-22396/com.dji.importSDKDemo D/com.dji.importSDKDemo.MainActivity: The metadata received from server is invalid, please reconnect to the server and try.
08-09 03:59:13.474 22370-22396/com.dji.importSDKDemo E/TAG: The metadata received from server is invalid, please reconnect to the server and try.
When I try to run the demo application on a emulator which uses the API 23 I get the following exception and the app crashes:
D/SDKRelativeJNI: Couldn't load lib E/art: No implementation found for java.lang.String dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString() (tried Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString and Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString__) E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.dji.importSDKDemo, PID: 5379 java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString() (tried Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString and Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString__) at dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString(Native Method) at dji.sdk.sdkmanager.DJISDKManager.<clinit>() at com.dji.importSDKDemo.MainActivity$1.run(Unknown Source)
Don't work for Android API 22,21,20,19. private void startSDKRegistration() { never get called.
// When the compile and target version is higher than 22, please request the following permission at runtime to ensure the SDK works well.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkAndRequestPermissions();
}
把这个demo编译通过,并在实体机上打开,却显示注册失败,密钥我已经填充,网络也已连接成功。
11/06 14:35:29: Launching 'ImportSDKDemo-app' on Nexus 6P API 29.
$ adb shell am start -n "com.dji.importSDKDemo/com.dji.importSDKDemo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 5257 on device 'Nexus_6P_API_29 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/i.importSDKDem: Not late-enabling -Xcheck:jni (already on)
E/i.importSDKDem: Unknown bits set in runtime_flags: 0x8000
W/i.importSDKDem: Unexpected CPU variant for X86 using defaults: x86
I/i.importSDKDem: The ClassLoaderContext is a special shared library.
I/i.importSDKDem: The ClassLoaderContext is a special shared library.
W/i.importSDKDem: Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
W/i.importSDKDem: Accessing hidden method Ldalvik/system/DexPathList;->makeInMemoryDexElements([Ljava/nio/ByteBuffer;Ljava/util/List;)[Ldalvik/system/DexPathList$Element; (greylist, JNI, allowed)
W/i.importSDKDem: Accessing hidden field Ldalvik/system/DexPathList;->dexElements:[Ldalvik/system/DexPathList$Element; (greylist, reflection, allowed)
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
W/RenderThread: type=1400 audit(0.0:17): avc: denied { write } for name="property_service" dev="tmpfs" ino=7388 scontext=u:r:untrusted_app_27:s0:c133,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.dji.importSDKDemo
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/i.importSDKDem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/i.importSDKDem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/HostConnection: HostConnection::get() New Host Connection established 0xdef80180, tid 5337
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation: eglCreateContext: 0xebdb6340: maj 3 min 1 rcv 4
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
glUtilsParamSize: unknow param 0x000082da
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: createUnique: call
HostConnection::get() New Host Connection established 0xdef81940, tid 5337
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1
D/eglCodecCommon: allocate: Ask for block of size 0x1000
allocate: ioctl allocate returned offset 0x3ffff4000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
I/i.importSDKDem: Background young concurrent copying GC freed 10420(4377KB) AllocSpace objects, 3(11MB) LOS objects, 81% free, 1368KB/7512KB, paused 7.577ms total 142.037ms
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
E/linker: "/data/app/com.dji.importSDKDemo-ZuHeQHAAq7Epn-lEnpP6Uw==/lib/x86/libffmpeg.so" has text relocations (https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#Text-Relocations-Enforced-for-API-level-23)
D/EGL_emulation: eglMakeCurrent: 0xebdb6340: ver 3 1 (tinfo 0xebda3ca0)
W/System.err: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.dji.importSDKDemo-ZuHeQHAAq7Epn-lEnpP6Uw==/lib/x86/libffmpeg.so" has text relocations (https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#Text-Relocations-Enforced-for-API-level-23)
W/System.err: at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
W/System.err: at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at dji.midware.natives.SDKRelativeJNI.(Unknown Source:6)
at dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString(Native Method)
at dji.sdk.sdkmanager.DJISDKManager.(Unknown Source:32)
at dji.sdk.sdkmanager.DJISDKManager.getInstance(Unknown Source:0)
at com.dji.importSDKDemo.MainActivity$1.run(Unknown Source:7)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
D/SDKRelativeJNI: Couldn't load lib
E/i.importSDKDem: No implementation found for java.lang.String dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString() (tried Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString and Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString__)
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.dji.importSDKDemo, PID: 5257
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString() (tried Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString and Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString__)
at dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString(Native Method)
at dji.sdk.sdkmanager.DJISDKManager.(Unknown Source:32)
at dji.sdk.sdkmanager.DJISDKManager.getInstance(Unknown Source:0)
at com.dji.importSDKDemo.MainActivity$1.run(Unknown Source:7)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
I/Process: Sending signal. PID: 5257 SIG: 9
Process 5257 terminated.
This demo app not is working on my Samsung Galaxy S7 Edge device with Android 6.0.1 OS.
Internet connectivity to the device is fine, I imported the project to Android Studio, install and run.
Android Studio Version : 2.3.1
Gradle Version set as : 2.10
App Key is also generated and inserted in the Manifest file.
Below is the app screen shot with error message.
There is a typo in the tutorial as well as the code in MainActivity.java
The two import modules should be:
import dji.common.error.DJIError;
import dji.common.error.DJISDKError;
instead of:
import dji.sdk.base.DJIError;
import dji.sdk.base.DJISDKError;
In the readme.md there is no mention about editing layout files, that may be confusing.
Following the official documentation https://developer.dji.com/mobile-sdk/documentation/android-tutorials/ImportAndActivateSDKInAndroidStudio.html developers should add a lot of permissions:
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Some of them android.permission.MOUNT_UNMOUNT_FILESYSTEMS
has errors/security issue (from play market):
This is maybe this is not issue, but question: Is dji sdk will be workable (or partically workable) if I remove the android.permission.MOUNT_UNMOUNT_FILESYSTEMS
permission?
I am now trying to connect to my Mavic 2 pro. However, I am still outside the door. Please help me with it.
First of all, when I download the code, it cannot run and lots of errors occured.
Secondly, when I come accross the DJISDKManager.getInstance().registerApp() with debug mode, everytime it failed here. This time I delete the assync and run it direct.
Thirdly, I have tried to remove MainActivity.this.getApplicationContext() with MainActivity.this, it still filled. Why?
The list of permissions is quite large - see below
private static final String[] REQUIRED_PERMISSION_LIST = new String[]{
Manifest.permission.VIBRATE,
Manifest.permission.INTERNET,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.WAKE_LOCK,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.CHANGE_WIFI_STATE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE,
};
Please also see here https://github.com/DJI-Mobile-SDK-Tutorials/Android-ImportAndActivateSDKInAndroidStudio/blob/master/ImportSDKDemo/app/src/main/java/com/dji/importSDKDemo/MainActivity.java#L37 and here https://github.com/DJI-Mobile-SDK-Tutorials/Android-ImportAndActivateSDKInAndroidStudio/blob/master/ImportSDKDemo/app/src/main/AndroidManifest.xml#L5
Why does the app need Manifest.permission.READ_PHONE_STATE? android.permission.MOUNT_UNMOUNT_FILESYSTEMS? (the latter is even shown as not allowed for the 3rd party apps on Android)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.