import com.google.api.client.googleapis.extensions not found - android

Why "import com.google.api.client.googleapis.extensions not found" is my case? I'm using android studio, android sdk 1.7.
I'm also add dependencies :
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.api-client:google-api-client:1.19.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.19.0' exclude module: 'httpclient'
Thanks alot!

You need add "-android", eg:
compile 'com.google.api-client:google-api-client-android:1.22.0'
(eg: the -android flavor)
https://github.com/google/google-api-java-client-samples/blob/master/tasks-android-sample/build.gradle has an example.

Related

failed to resolve com.android.support:support-v7:25.2.0

exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v7:25.2.0'
compile 'com.android.support:design:25.1.1'
}
failed to resolve com.android.support:support-v7:25.2.0
Am trying but cant find the solution please help me
If you are trying to get the support repository, this is the correct import:
compile "com.android.support:support-v4:25.3.1"
If your compile api isn't 25, change the version to the latest with your compile api
If it isn't any of these you have to add some context: What is it intent of the import? What do you need it for?
Side note
I [believe] the repository you are trying to get is the support repository. The support repository is v4, not v7.

Android app and library dependencies clash

my app uses these dependencies
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.google.code.gson:gson:2.2.4'
when i imported seek arc library it uses different dependencies
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile project(':SeekArc_library')
How can i solve this problem ?
I am assuming you are using the standard gradle build tooling and Android Studio.
Below is the recommended solution for issues of clashing dependencies. Eg say you have declared an explicit dependency on com.google.guava version X but some other dependency is bringing its own internal dependency on com.google.guava version X-1.
Add the following after your dependencies clause in the build.gradle file.
configurations {
all*.exclude group: 'com.google.guava', module: 'guava-jdk5'
}
For details see https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html
Note: there is another approach where you may selectively exclude certain dependency from each compile clause but it is not recommended since it doesn't scale well. For completeness I'll include it here but I do not recommend it. Using the same made-up example as above
compile(group: 'com.google.guava', name: 'guava', version: 'X')
compile(group: 'com.some.other.dependency', name: 'foo', version: 'bar')
{
// exclude transitive dependency since we want to depend on version `X` declared above
exclude(group: 'com.google.guava', module: 'guava-jdk5')
}
My App and newly added Library dependencies were in conflict. I changed app compiled & build sdk to api 23 and added "useLibrary 'org.apache.http.legacy'". Now problem solved.
The top level applications library dependency will override the lower level library dependency . You don't need to override explicitly. Refer to Android build documentation
If you want to exclude the dependancies of the library you are using you can
compile 'yourLibraryName'{
exclude module: 'appcompat-v7'
exclude module: 'appcompat-v7'
}
Make sure you provide your own version though, otherwise you'll get runtime errors

Gradle dependency exclusion

I've a project A and a project B. Project A is a core project used by other projects too. Here's his build.gradle dependencies:
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile('org.simpleframework:simple-xml:2.7.1') {
//http://stackoverflow.com/a/19455878/1423773
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.5'
}
Since it's a core project having the latest dependencies versions makes sense. Project B uses a dependency that uses httpcore-4.2.4.jar and it will throw a duplicate dependency error if I don't modify my core project build.gradle to:
dependencies {
...
// compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpcore:4.2.4'
compile('org.apache.httpcomponents:httpmime:4.5') {
exclude module: 'httpcore'
}
}
And this is something I would like to avoid because I don't want to change my core project build.gradle.
What's the best solution for this situation? If I removed/exclude the .jar from my other dependency would work? If so, how can I remove it? I've tried exclude module/group but without any luck. Something I was thinking of was Chapter 56. Multi-project Builds (I haven't read yet) but I would like to avoid having different gradle.build files in my core project for every non-core project.
My project B conflict dependency: co.realtime:messaging-android:2.1.40
Thanks.
I found it, It was in front of me all the time...
So inside my project B I just have to follow the same approach I used in my core project:
compile (project(':submodules:MyCoreProject')){
exclude module: 'httpcore'
//co.realtime:messaging-android:2.1.40
//uses 'org.apache.httpcomponents:httpcore:4.2.4'
}
and now my core project:
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile('org.simpleframework:simple-xml:2.7.1') {
//http://stackoverflow.com/a/19455878/1423773
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.5'
}

Exclude support v4 in gradle to remove duplicate but getting java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14

I have an old eclipse based project , and i converted it to android studio based. The convertion success, but i have problem when adding other dependency, first i get error java.exe finished with non-zero exit value 2, because of duplicate dependency support v4, and i try to exlude modul support v4, but now im getting java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
this is my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SlidingMenu')
compile project(':PhotoView')
compile project(':viewpager')
compile project(':StackBlur')
compile project(':FacebookSDK')
compile files('libs/LibAllShareInterface_2.0.0.jar')
// Exclude module support-v4 to remove duplicate
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:design:22.2.0') { exclude module: 'support-v4' }
compile('com.squareup.picasso:picasso:2.5.2') { exclude module: 'support-v4' }
compile('com.android.support:recyclerview-v7:21.0.0') { exclude module: 'support-v4' }
compile('com.android.support:cardview-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:support-annotations:22.2.0') { exclude module: 'support-v4' }
}
Any help will be appreciated
Well although I am not gradle expert and I'm experiencing some problems myself, I was able to reproduce an error complaining about appcompat-v4, using your dependencies.
It seems that you are completely excluding support-v4 from all your dependencies, and since support-v4 is required, you must either specify it as a dependency separately, or change this:
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
to this:
compile ('com.android.support:appcompat-v7:22.2.0')
so you don't exclude support-v4 completely from your project.
I did the second and the project could build (A sample project with just those dependencies defined).

Crouton depends on libraries but is not a library itself

I'm using Android Studio 0.6.1, with Crouton library and today after gradle sync I got next error:
Error:A problem occurred configuring root project 'project_name'.
Module version de.keyboardsurfer.android.widget:crouton:1.8.4 depends on libraries but is not a library itself
That's going on?
This issue due to com.android.support-v4 recent update.
So I changed
compile 'com.android.support:support-v4:20.+'
to
compile 'com.android.support:support-v4:19.1.+'
and crouton works fine
Different workaround is to use #aar:
compile('de.keyboardsurfer.android.widget:crouton:1.8.4#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
My solution according to #Revedko answer, using #aar and change all supports to version lower than 21 -> 20.+
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.loopj.android:android-async-http:1.+'
compile "com.bugsense.trace:bugsense:3.5"
compile('de.keyboardsurfer.android.widget:crouton:1.8.4#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:5.0.77'
}

Categories

Resources