I connect to the project the library Retrofit , connected

  compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' 

In Gradle , In Activit Added

 import retrofit.client.Response; import retrofit.http.GET; 

but still does not see the class Retrofit for example

 Retrofit retrofit = Retrofit.Builder() 

What could be the error? And do I connect correctly?

apply plugin: 'com.android.application'

 android { compileSdkVersion 25 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.example.hp.apps" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.google.code.gson:gson:2.8.0' compile 'com.github.nkzawa:socket.io-client:0.3.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'org.apache.httpcomponents:httpclient:4.5' compile 'com.squareup.retrofit2:retrofit:2.3.0' testCompile 'junit:junit:4.12' } 
  • You can complete the code of the build.gradle file in which dependencies were - Danil
  • Added code to build.gradle - Clarence
  • Enable auto import in the settings. - Cypher

1 answer 1

You Retrofit 2 connect, and import it in the code

 import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response;