Challenges with File Generation and Logging in Android Scoped Storage Using DJI SDK
已完成Hello DJI Developer Community,
I am encountering a significant issue with the DJI SDK in relation to Android's Scoped Storage rules, specifically when trying to generate KMZ files and write to log files in the /sdcard
directory. I seek your insights and suggestions on how to navigate this problem.
1. Issue Overview: My application, which integrates the DJI SDK, is facing permission-related problems in Android 10 and above due to Scoped Storage restrictions. The app fails to generate KMZ files and write to log files in the /sdcard
directory without the MANAGE_EXTERNAL_STORAGE
permission.
2. Code Examples: Here are the key parts of my code where the issues occur:
- KMZ File Generation (in
convertToSDKFormat
method):WPMZManager.getInstance() .generateKMZFile(waylineKMZPath, waylineMission, missionConfig, template)
- Log File Path Initialization (in
PPALController.class
):static { try { System.loadLibrary("ppal-jni"); initLogPath("/sdcard/ppal.log"); } catch (UnsatisfiedLinkError var1) { Log.e("PPALController", "Couldn't load lib-ppal-jni! e=" + var1.getMessage()); } }
3. Error Messages: I am receiving permission denied errors when trying to access /sdcard
.
4. Scoped Storage Impact: The issue appears to stem from the Scoped Storage implementation in Android 10+, which restricts access to directories like /sdcard
.
5. Current Workaround: Using MANAGE_EXTERNAL_STORAGE
seems to solve the problem, but I am aware this permission is not recommended for widespread use and might not align with Google's guidelines.
6. Seeking Guidance: I would greatly appreciate any advice on how to handle file generation and logging within the Scoped Storage constraints, specifically for apps using the DJI SDK. Are there best practices or alternative approaches recommended for this scenario?
7. Potential Solutions: I am considering using app-specific directories or modifying the SDK's file management methods. I welcome feedback on these ideas or any other solutions.
Thank you in advance for your help and suggestions!
-
I regret to inform you that the matter you have raised falls outside the purview of our technical support services. It is necessary for you to resolve this matter independently. It is worth noting that our sample code has been successfully resolved by obtaining the MANAGE_EXTERNAL_STORAGE permission.
请先登录再写评论。
评论
1 条评论