Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I download an old version of the Android support library?

I'm targeting Android 19 (because that's what my phone is running). I want to add a notification with buttons; it seems the right approach is to use appcompat-v7.app.NotificationCompat.

However, when I add appcompat-v7 from the Android Support repository revision 22.2 (via a build.gradle dependency), it includes a file app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values-v21/values-v21.xml that doesn't compile because it assumes the target is 21+.

I tried deleting that file, but it gets regenerated.

There doesn't seem to be a way to exclude a file from the build.

So, I need to get an older version of the support library or repository, that doesn't include 21 stuff.

I guess I could import all the sources directly (and leave out the v21 stuff), rather than thru the dependency? I'm not clear where to start with that. I can use the SDK manager to get older versions of the SDK, but it only offers the latest version of the support library.

like image 855
Stephen Leake Avatar asked Jul 09 '15 15:07

Stephen Leake


2 Answers

to directly answer your question it's all that one line on gradle:

compile 'com.android.support:appcompat-v7:22.2.0'

That last part is the version you're getting. 22.2.0 on the example above.

and on this link you can check the revisions numbers: https://developer.android.com/tools/support-library/index.html#revisions

But you have a fundamentally wrong approach to your issue. You don't have to target the API for the device you have with you. You can easily and safely target the latest API, use the latest AppCompat features and bug fixes.

Lint will give you a warning every time you try to use a feature that is not from your minimumApi, regardless of the targetAPI

like image 138
Budius Avatar answered Oct 16 '22 14:10

Budius


In your gradle build file change the dependency to be the 19 version (the version of the library should match the sdk you are compiling with):

dependencies {
    compile 'com.android.support:appcompat-v7:19.1.+'
...
}

Edit: If v19 of the support lib doesn't have NotificationCompat, then you can't use that unless you compile against a later SDK. You can't include a support library with a higher version than your compiled SDK - that's the issue you are running into.

In this case change:

android {
    compileSdkVersion 22
    ...
}

and leave the dependency set to the 22 version of the appcompat support lib

like image 2
jt-gilkeson Avatar answered Oct 16 '22 13:10

jt-gilkeson