Android app I have login with twitter , click TwitterLoginButton , retrofit error occur

android
fabric
oauth
api

#1

Hi ,

@lientm @TwitterApi @gpj @bonnell

I have integrate the twitter login in developing app , I click the Twitter Login Button I am getting error message show is logcat. And I have used ,

//Networking Libraries
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2’
compile ‘com.squareup.okhttp:okhttp:2.5.0’
//Google Gson convertor
compile ‘com.squareup.retrofit:converter-gson:2.0.0-beta2’
//Http request and response Logging
compile ‘com.squareup.okhttp:logging-interceptor:2.6.0’

for API calls.

Please give the ideas to fix the issue. Thanks …

Logcat Error :
03-17 19:36:59.047 23896-23896/com.giveback360 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example, PID: 23896
java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/RestAdapter$Builder;
at com.twitter.sdk.android.core.internal.oauth.OAuthService.(OAuthService.java:50)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService.(OAuth1aService.java:74)
at com.twitter.sdk.android.core.identity.OAuthActivity.onCreate(OAuthActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
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.giveback360-1/base.apk”],nativeLibraryDirectories=[/data/app/com.example-1/lib/arm, /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.(OAuthService.java:50)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService.(OAuth1aService.java:74)
at com.twitter.sdk.android.core.identity.OAuthActivity.onCreate(OAuthActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
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)
… 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available


#2

@Saravanank2k Retrofit 2 is not currently supported by TwitterKit, however you can use the workaround offered here.


#3

Hi @bonnell

Thanks … :slight_smile:

I have tried the libraries you have referred but I got same issue ,

//Networking Libraries
compile 'com.squareup.retrofit:retrofit:1.9.0’
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4’
compile 'com.squareup.okhttp:okhttp:2.7.4’
compile ‘com.squareup.okhttp:okhttp-urlconnection:2.7.4’

Logcat output

Process:
java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/RestAdapter$Builder;
at com.twitter.sdk.android.core.internal.oauth.OAuthService.(OAuthService.java:50)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService.(OAuth1aService.java:74)
at com.twitter.sdk.android.core.identity.OAuthActivity.onCreate(OAuthActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
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.example-2/base.apk”],nativeLibraryDirectories=[/data/app/com.example-2/lib/arm, /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.(OAuthService.java:50)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService.(OAuth1aService.java:74)
at com.twitter.sdk.android.core.identity.OAuthActivity.onCreate(OAuthActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
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)
… 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available


#4

I just tested by adding in only the compiled additional libraries you mentioned originally and couldn’t reproduce this.

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.twitter.mbonnell.miketesttwitterkit"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile('com.twitter.sdk.android:twitter:1.13.0@aar') {
        transitive = true;
    }
    //Networking Libraries
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    //Google Gson convertor
    compile 'com.squareup.retrofit2:converter-gson:2.0.0'
    //Http request and response Logging
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}

Can you share your full build.gradle?


#5

Note: The final version of Retrofit 2.0 has been released. Users should migrate off beta. Early version of beta used the same package name as Retrofit 1.x which will cause issues. Once dependencies are updated you will also likely have to do a clean build.