Mohit Gaur Mohit Gaur - 5 months ago 89
Android Question

Android application just crashes with twitter digits and Retrofit

I am working on android application.I am using twitter digits for authentication.
With the help of twitter digits app is working but whenever i am using Retrofit,the app crashes.

Below is my Log cat:

FATAL EXCEPTION: main
Process: com.shikshabharti.edumedia24, PID: 500
java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/RestAdapter$Builder;
at com.twitter.sdk.android.core.internal.oauth.OAuthService.<init>(OAuthService.java:51)
at com.twitter.sdk.android.core.internal.oauth.OAuth2Service.<init>(OAuth2Service.java:60)
at com.digits.sdk.android.DigitsGuestSessionProvider.<init>(DigitsGuestSessionProvider.java:38)
at com.digits.sdk.android.DigitsClient.createAuthRequestQueue(DigitsClient.java:98)
at com.digits.sdk.android.DigitsClient.<init>(DigitsClient.java:86)
at com.digits.sdk.android.DigitsClient.<init>(DigitsClient.java:58)
at com.digits.sdk.android.Digits.createDigitsClient(Digits.java:251)
at com.digits.sdk.android.Digits.getDigitsClient(Digits.java:240)
at com.digits.sdk.android.Digits.authenticate(Digits.java:147)
at com.digits.sdk.android.Digits.authenticate(Digits.java:101)
at com.shikshabharti.edumedia24.activities.RegistrationActivity.onCreate(RegistrationActivity.java:77)
at android.app.Activity.performCreate(Activity.java:5966)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2517)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5530)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: java.lang.ClassNotFoundException: Didn't find class "retrofit.RestAdapter$Builder" on path: DexPathList[[zip file "/data/app/com.shikshabharti.edumedia24-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.twitter.sdk.android.core.internal.oauth.OAuthService.<init>(OAuthService.java:51) 
at com.twitter.sdk.android.core.internal.oauth.OAuth2Service.<init>(OAuth2Service.java:60) 
at com.digits.sdk.android.DigitsGuestSessionProvider.<init>(DigitsGuestSessionProvider.java:38) 
at com.digits.sdk.android.DigitsClient.createAuthRequestQueue(DigitsClient.java:98) 
at com.digits.sdk.android.DigitsClient.<init>(DigitsClient.java:86) 
at com.digits.sdk.android.DigitsClient.<init>(DigitsClient.java:58) 
at com.digits.sdk.android.Digits.createDigitsClient(Digits.java:251) 
at com.digits.sdk.android.Digits.getDigitsClient(Digits.java:240) 
at com.digits.sdk.android.Digits.authenticate(Digits.java:147) 
at com.digits.sdk.android.Digits.authenticate(Digits.java:101) 
at com.shikshabharti.edumedia24.activities.RegistrationActivity.onCreate(RegistrationActivity.java:77) 
at android.app.Activity.performCreate(Activity.java:5966) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2517) 
at android.app.ActivityThread.access$800(ActivityThread.java:162) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:189) 
at android.app.ActivityThread.main(ActivityThread.java:5530) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 
Suppressed: java.lang.ClassNotFoundException: retrofit.RestAdapter$Builder
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 25 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available


This my compile dependency

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.squareup.okhttp:okhttp:2.7.3'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.3'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile('com.digits.sdk.android:digits:1.10.3@aar') {
transitive = true;
}


Before adding retrofit dependency app is crashing.Please provide me the solution for that.

Answer

You are not using the same version for retrofit and its converter.Try this version:

compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.google.code.gson:gson:2.6.2'