I have included below libraries to my app's lib folder:
When going to run app it gives me such an error:
Error:(17, 17) error: cannot access HttpUrl class file for com.squareup.okhttp.HttpUrl not found
I have created app including retrofit as said here: The biggest update yet on the best HTTP Client Library for Android
As there said: But in Retrofit 2.0, OkHttp is now required and is automatically set as a dependency.
-- So, did not add OkHttp to my project
As there said: But in Retrofit 2.0, Converter is not included in the package anymore. You need to plug a Converter in yourself or Retrofit will be able to accept only the String result. As a result, Retrofit 2.0 doesn't depend on Gson anymore.
-- So, i decided include Gson: com.squareup.retrofit:converter-gson to my app, not 'com.google.code.gson:gson:2.3.1'
Any advises how to use retrofit will be helpful. And please advice me how to correct this main Error?
Solved: I searched and find this solution. If you are using proxy to connect internet then simply add it to gradle.properties file:
systemProp.http.proxyHost=xxx systemProp.http.proxyPort=xxx systemProp.http.proxyUser=xxx systemProp.http.proxyPassword=xxx systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
systemProp.https.proxyHost=xxx systemProp.https.proxyPort=xxx systemProp.https.proxyUser=xxx systemProp.https.proxyPassword=xxx systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
Thanks to @ilya. It was just network issue
Jars doesn't contain any information about its dependencies So when you are adding jars you also have to download and add OkHttp/Gson jars.
compile files('libs/okhttp.jar')
compile files('libs/gson.jar')
But if you add your dependency in this way
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
All other required libraries will be downloaded and added by gradle automatically.
The final gradle.build should contain these 2 lines:
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With