I have recently started getting this issue with Android Studio and it has been driving me up the wall. I keep getting the error "Failed to resolve: com.squareup.okio:okio:1.8.0". These are the dependencies I have:
dependencies {
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile files('libs/okio-1.8.0.jar')
compile files('libs/retrofit-2.1.0 (1).jar')
}
As you can see, I have the retrofit and gson libraries simply compile (I'm assuming this downloads them from the internet), I tried doing the same with Okio however it didn't resolve, so I have speicifcally downloaded the 1.8.0 Okio JAR however it still fails to resolve. Why could this be? Any answer would be greatly appreciated. Thank you
Don't put dependencies as a Gradle dependency:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
And as a .jar file in src/libs:
compile files('libs/retrofit-2.1.0 (1).jar')
at one time. Choose only one method. I advise you to choose Gradle dependencies, because they are automatically fetched.
In you case, the dependencies section should look like:
dependencies {
compile `com.google.code.gson:gson:2.7`
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
}
Related
In my organization due security they restricted network like social media sites, other sites. Because of this, I am unable to add some Android dependencies in my project build.gradle.
Eg:-
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
But I am able to add default android dependencies like below.
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:multidex:1.0.1'
So, here my question is what are the generic URLs need to be enable to get all dependencies build.gradle. I will ask them to enable those URLs.
Thanks in advance
I believe URls are dependency specific, will very from one to other.
Why don't you configure your gradle for proxy?
Complete answer here
After I updated my Support library from 23.1.1 to 23.4.0 I get this warning cannot access android.support.v4.app.baseFragmentActivityEclair on every call to super and every instance of AppCompatActivity
And if I updated my support library to 24.1.1 The warning changes to cannot access android.support.v4.app.baseFragmentActivityJB.
Can anyone tell me why this warning is shown and how can I remove this warning:
here is my dependencies before:
(no error in this)
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
here is my dependencies after cannot access android.support.v4.app.baseFragmentActivityEclairwarning:
compile 'com.android.support:palette-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
here is my dependencies after cannot access android.support.v4.app.baseFragmentActivityJBwarning:
compile 'com.android.support:palette-v7:24.1.1'
compile 'com.android.support:gridlayout-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
We ran into a similar problem when one of the packages in our project had dependencies on version 24.0 support libraries and another package was dependent on version 23.4.0. This seems to be a problem for the Android Studio (IntelliJ) IDE, not the compiler, because we were able to build and run the project without any problems. We resolved the warning by reverting the 24.0 dependency to 23.4.0. I suspect that going the other direction (advancing all of our package dependencies to 24.0) would also have eliminated the warning but we didn't experiment with that due to the number of packages in our project.
If you're looking to hack around this, many of the support libraries have an internal library called libs/internal_impl-$VERSION.jar that includes these types of version-specific implementations. To get your IDE to work, you can extract these JARs and manually include them in your IDE's build path.
For example, you can extract the classes referenced here, assuming version 24.2.1, using this command:
unzip support-fragment-24.2.1.aar libs/internal_impl-24.2.1.jar
I have recently added FCM to my project and it's working fine. I have used
compile 'com.google.firebase:firebase-messaging:9.0.2'
this line for the library since messaging service is only required. But when I have seen the external libraries dir there are many firebase classes which have no use in my app. Please see the image below.
Edited : Here is the whole dependency clause
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.4.3'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
You are including more libraries than you need because you are using the general play-services library and not using the split libraries like play-services-drive or some other specific library.
By using play-services:9.0.2 you are saying you want to include all libraries in Google Play services including all the Firebase ones.
Removing the play-services:9.0.2 dependency and replacing it with a specific one like play-services-drive:9.0.2 (depending on what APIs you want to use) should fix your issue.
I believe since you don't add the core lib dependency explicity. The messaging dependency downloads all of the Firebase one.
Try adding the core and messaging both to limit the things to messaging part
compile 'com.google.firebase:firebase-core:9.0.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'
Does gradle automatically imports the dependencies of the dependencies?
For example in an Android application I have those:
dependencies {
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
#######compile 'com.google.code.gson:gson:2.3'
}
okhttp and retrofit use Gson.
Do I have to include Gson manually or it is resolved by gradle automatically?
If I include Gson manually, does gradle imports the library twice and thus increasing my application size?
So far Retrofit itself used GSON and it should import the GSON dependencies automatically once you compile 'com.squareup.retrofit:retrofit:1.9.0'.
When using Retrofit together with OkHttp, OkHttp (version 1.6.0 or newer) and OkHttp-UrlConnection is required.
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
I applied following library dependencies,In my android studio take only com.android.support:appcompat-v7:21.0.+ like that and all google dependencies.If i apply private library dependencies like following
Failed to find:it.neokree:MaterialTabs:0.11![Failed to find library dependencies in build.gradle android studio][1]
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'org.lucasr.dspec:dspec:0.1.1'
compile 'it.neokree:MaterialTabs:0.11'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.telly:mrvector:0.2.0'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'me.tatarka.support:jobscheduler:0.1.1'
compile 'jp.wasabeef:recyclerview-animators:1.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.android.support:gridlayout-v7:22.0.0'
}
Failed to find library dependencies in build.gradle android studio.
I researched so many times and tried so many ways.but i can't find solutions.i don't know this is a studio gradle problems or my company blocked some firewalls certificate for security.I want to solutions urgent.please somebody solve this problem and help for me.currently i have used jar files only.If i used jar files through libs folder then what is diffrent between eclipse and android studio/
Try sync gradle again and check if you can link to this page:
https://jcenter.bintray.com/it/neokree/MaterialTabs/maven-metadata.xml
If you can't, if might be the firewall problem.
And some dependencies might out of date.
I help you to sync the latest version using andle
com.android.support:appcompat-v7: 21.0.+ -> 23.1.0
com.android.support:recyclerview-v7: 21.0.+ -> 23.1.0
com.mcxiaoke.volley:library: 1.0.+ -> 1.0.19
jp.wasabeef:recyclerview-animators: 1.1.0 -> 2.0.1
com.daimajia.easing:library: 1.0.1 -> 1.0.2
com.android.support:gridlayout-v7: 22.0.0 -> 23.1.0