dji-sdk / Mobile-SDK-Android

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

Unable to generate signed APK due to duplicate entry gson #150

Closed kwong93 closed 7 years ago

kwong93 commented 7 years ago

Here are my gradle dependencies

I verified that I can build the signed APK when I commented out the DJI dependencies

    compile project(':dji-uilibrary')
    compile project(':dji-sdk')
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'com.google.android.gms:play-services-maps:10.2.4'
    compile 'com.github.chrisbanes:PhotoView:2.0.0'
    compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'
    compile 'com.google.maps.android:android-maps-utils:0.5+'
    compile 'com.squareup.okhttp3:okhttp:3.8.0'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxjava:2.1.0'
    compile 'com.google.android.gms:play-services-location:10.2.6'
    compile 'com.library.tangxiaolv:telegramgallery:1.0.3'
    compile 'com.github.barteksc:android-pdf-viewer:2.6.0'
    compile project(':dji-uilibrary')
    compile project(':dji-sdk')
}
kwong93 commented 7 years ago

I opened the dji-sdk.aar file (got this from https://github.com/dji-sdk/Mobile-UILibrary-Android/tree/master/libs) and I see the gson dependency dji-sdk.aar\classes.jar\com\google\gson\

and also I see another module dji.thirdparty.gson.

Question is which one is being used? I did a brief scan and I don't see any references to com.google.json I would like to remove the com.google.gson completely from classes.jar and remake the aar to see if will solve the conflict

Edit:

I removed google/ folder from classes.jar using 7zip and tried to build again and it worked, I tested the functions I had like view captures and take photo and they all work, but I don't know if it breaks other functions I wasn't using

oliverou commented 7 years ago

Hi @kwong93, please try the logIntoDJIUserAccount interface to test if it works, if so, you are good to go.

For the gson dependency "dji-sdk.aar\classes.jar\com\google\gson\", currently, we don't plan to remove it in our SDK.

kwong93 commented 7 years ago

@oliverou Is logging in required to use drone capabilities? What is the difference for a logged in user and and an anonymous user using my app with dji integration?

oliverou commented 7 years ago

Hi @kwong93, the login and application activation is required for users in China, please check the introduction section of this tutorial: Application Activation and Aircraft Binding.

justintuchek commented 7 years ago

@kwong93 I believe the build issue you're having is a transitive dependency conflict between the version of Gson being used by com.squareup.retrofit2:converter-gson and the version being used by ':dji-uilibrary'

You could look into using a Gradle command to exclude the command package under - documented here 25.4.7. Excluding transitive dependencies https://docs.gradle.org/3.3/userguide/dependency_management.html

Maybe the UI Library should use a Gradle provided scope to rely on compile time dependencies from the mobile SDK - otherwise a user using both the SDK and the UI library will ship 2 versions of Gson.

It's also not very friendly to people just getting started as multiple namespace paths for the same library can be confusing and if not stripped out it may push them into having to maintain a multidex application which is a significantly slower experience.

kwong93 commented 7 years ago

Now that DJI has the sdks availabe via gradle, this is no longer an issue for me

    compile 'com.dji:dji-sdk:4.3.2'
    compile 'com.dji:dji-uilibrary:4.3.2'