Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio .2.2 and Gradle package does not exist

New to Android Studio and to importing external Java libs. I have read the posts on configuring Gradle dependencies and I fixed my first package does not exist error.

These are the import statements from my MainAcitivity.java file:

import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.api.client.extensions.android.http.AndroidHttp;
import om.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.tasks.TasksScopes;

and here are my dependencies statements from the build.gradle file.

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile 'com.google.android.gms:play-services:3.1.36'

I happened to stumble upon a post that specifically mentioned how to fix the import GooglePlayServicesUtil Gradle package error.

I need to add the add the other dependencies for the other 6 external imports but don't know how to find out what to name them as it is not clear to me why import com.google.android.gms.common.GooglePlayServicesUtil; maps to compile 'com.google.android.gms:play-services:3.1.36'

How do I find out what the other import to dependency mappings are for the other 6 external libs?

com.google.api.client.extensions.android.http.AndroidHttp;

com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;

com.google.api.client.http.HttpTransport;

com.google.api.client.json.JsonFactory;

com.google.api.client.json.gson.GsonFactory;

com.google.api.services.tasks.TasksScopes;

Really looking for the method on how to do this with any external imported java lib.

Thanks for your help!

like image 208
user2283116 Avatar asked Jul 30 '13 20:07

user2283116


2 Answers

Add these dependencies:

compile ('com.google.api-client:google-api-client-android:1.17.0-rc') {
    exclude module: 'httpclient'
}
compile ('com.google.http-client:google-http-client-gson:1.17.0-rc') { 
    exclude module: 'httpclient'
}

See this example

like image 140
Nipper Avatar answered Nov 06 '22 09:11

Nipper


I had the same problem after updating all of the dependencies in my project. Originally I did have the httpClient exclusion, but it was configured differently...

configurations {
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
} 

dependencies {
    compile 'com.google.api-client:google-api-client:1.22.0'
    compile 'com.google.http-client:google-http-client-gson:1.22.0'
}

I changed it to use Nipper's example and all is well!

// removed configuration exclusion

dependencies {
    compile ('com.google.api-client:google-api-client-android:1.22.0') {
        exclude module: 'httpclient'
    }
    compile ('com.google.http-client:google-http-client-gson:1.22.0') { 
        exclude module: 'httpclient'
    }
}
like image 22
Joetron Avatar answered Nov 06 '22 09:11

Joetron