OAuth in Android App

I need to use the OAuth protocol in an Android app. I decided to use android-oauth-client . In my build.gradle file, I have:

 dependencies { compile 'com.android.support:appcompat-v7:21.0.0' compile 'com.wu-man:android-oauth-client:0.0.3' } 

The gradle file sync project works fine, but when I try to create an application, a problem occurs:

Error: execution completed for task ': app: dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command' C: \ Program Files \ Java \ jdk1.7.0_51 \ bin \ java.exe '' completed with- zero value of output 2

I found that I should try to add multiDexEnabled true to defaultConfig in the build.gradle section. The first problem is solved, but there is one more:

Error: execution completed for task ': app: packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: android / support / v4 / accessibilityservice / AccessibilityServiceInfoCompat $ AccessibilityServiceInfoIcsImpl.class

I have no idea how to fix this and how I can build my project. could you help me? Thanks in advance.

+1
source share
1 answer

The support-v4 transitive dependency is added twice. You can test it using either the dependency task or the dependency report:

 MacBook-Pro:demo alex$ ./gradlew app:dependencies --configuration compile 

or:

 MacBook-Pro:demo alex$ ./gradlew app:dependencyInsight --configuration compile --dependency support-v4 

Where demo is the root directory of your project. The output for compilation configuration will be:

 compile - Classpath for compiling the main sources. +--- com.android.support:appcompat-v7:21.0.0 | \--- com.android.support:support-v4:21.0.0 | \--- com.android.support:support-annotations:21.0.0 \--- com.wu-man:android-oauth-client:0.0.3 +--- com.google.oauth-client:google-oauth-client-java6:1.15.0-rc | \--- com.google.oauth-client:google-oauth-client:1.15.0-rc | +--- com.google.http-client:google-http-client:1.15.0-rc | | \--- com.google.code.findbugs:jsr305:1.3.9 | \--- com.google.code.findbugs:jsr305:1.3.9 +--- com.google.http-client:google-http-client-jackson:1.15.0-rc | +--- com.google.http-client:google-http-client:1.15.0-rc (*) | \--- org.codehaus.jackson:jackson-core-asl:1.9.11 +--- com.google.android:support-v4:r7 \--- com.google.api-client:google-api-client-android:1.15.0-rc +--- com.google.api-client:google-api-client:1.15.0-rc | \--- com.google.oauth-client:google-oauth-client:1.15.0-rc (*) \--- com.google.http-client:google-http-client-android:1.15.0-rc \--- com.google.http-client:google-http-client:1.15.0-rc (*) 

And the output of the dependency report will look like this:

 :app:dependencyInsight com.android.support:support-v4:21.0.0 \--- com.android.support:appcompat-v7:21.0.0 \--- compile com.google.android:support-v4:r7 \--- com.wu-man:android-oauth-client:0.0.3 \--- compile 


Please note that both appcompat-v7 and android-oauth-client depend on support-v4 . You can easily solve this problem by eliminating the android-oauth-client dependency:

 dependencies { compile 'com.android.support:appcompat-v7:21.0.0' compile ('com.wu-man:android-oauth-client:0.0.3') { exclude group: 'com.google.android', module: 'support-v4' } } 
+7
source

All Articles