0

I am trying to develop using the Gmail API for Android for devices with API 21. In this tutorial: https://developers.google.com/gmail/api/quickstart/android It says I need to have:

Android SDK packages for API 23 or later, including the latest versions of Google Repository, Android Support Library and Google Play Services.

And the dependencies example there is:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'pub.devrel:easypermissions:0.1.5'
compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev47-1.22.0') {
    exclude group: 'org.apache.httpcomponents'
} 
}

But I get an error when I use it saying I cant use: com.android.support:appcompat-v7:23.4.0 When my compile SDK version is 21.

I've tried changing the appcompact version to v7:21.0.2 which worked for me before, but when I sync the gradle files I get the error:

Error: Failed to resolve: com.android.support:appcompat-v7:23.1.1
Install Repository and sync project
Open File
Show in Project Structure dialog

But installing this repository will create the problem of the support library not matching the compile version.

Am I doing something wrong?

Tal Mantelmakher
  • 994
  • 1
  • 7
  • 23
  • Maybe that is the reason, because like you said you used deprecated features. So the best way is to update the code that you are using and use the latest version of android sdk like in the [documentation](https://developers.google.com/gmail/api/quickstart/android). So after you use the sdk 23, you will not have any problem using the appcompat-v7:23.4.0 – KENdi Aug 02 '16 at 07:34

1 Answers1

0

You can try to go to SDK manager and install three component: Google Repository, Android Support Library and Google Play Services. like following picture: enter image description here

xxx
  • 3,315
  • 5
  • 21
  • 40
  • I have all of them installed already. Although the Android Support Repository revision I have is 33 and I can update it to 35. – Tal Mantelmakher Aug 01 '16 at 14:13
  • Yes, update to the latest version. also update the SDK Build-tools to 23 – xxx Aug 01 '16 at 14:23
  • I updated the Android support Repository and the Android SDK Build-tools to 23. Now when I Sync i get these errors: `Error retrieving parent for item: No resource found that matches the given name` 1. 'android:TextAppearance.Material.Widget.Button.Inverse'. 2. 'android:Widget.Material.Button.Colored'. And I still get the: `The support library should not use a different version that the compileSdkVersion` error if I try to use the appcompat-v7:23.4.0 dependency. – Tal Mantelmakher Aug 01 '16 at 14:41
  • Your compile SDK version must match the support library's major version. I think this link is helpful for you: http://stackoverflow.com/questions/32075498/error-retrieving-parent-for-item-no-resource-found-that-matches-the-given-name – xxx Aug 01 '16 at 14:53
  • But I cannot do that since my code doesnt compile for android sdk 23. Does this mean it is impossible to use Gmail API for android sdk 21? Edit: It doesnt compile because I'm using deprecated features from Android API 21. Is the only way to get around this is to update my code to compile against android sdk 23? – Tal Mantelmakher Aug 01 '16 at 14:59