Android Studio always load old revision of support library - android

When I write code in Android Studio with some features from android support library it is ok, but when I try to build application, it cannot recognize some methods from support library. In "External library" I see that there is android-support-library revision 7, but in gradle file I wrote
compile 'com.android.support:support-v4:20.+'
I can't figure out what's the problem? and how can i solve it, could you please help me?

Just don't use the + sign:
compile 'com.android.support:support-v4:20.0.0'
So you can choose any fixed version number.
However the newest version was on Friday 21.0.2. I didn't check it in the meantime.

Related

How to fix "Rendering Problems The following classes could not be instantiated"?

I just started learning android coding and I keep getting this error:
Add these support library in build.gradle and also make sure the version of the support library(goto sdk manager and get the version number of sdk platform and place it in below dependancy because version of support library and sdk platform should be matched)
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
Try any of the following
Click refresh button on the preview pane
Sync Project with Gradle files
Click Tools > Android > Sync Project with Gradle Files
Rebuild Project
Click Build > Rebuild Project
This seems to come up periodically with Android Studio and it happened again today on an install I haven't used in a while. There may be more than one solution, but as of today June 08, 2016, I made sure two things are set:
1) Make sure you're on SDK/API 23 (or lower if necessary) vs the N preview, and
2) change the theme to "App theme". You may have to choose "Manifest Theme" in the left column before you can see "App Theme" show up as an option in the right column.
3) hit the refresh button (looks like two arrows in a circle)
Referring to a post above, both the support.appCompat and support.design libraries should be automatically added as dependencies to the gradle file, but you can double check them if necessary (and get the newest ones if the versions have changed).
You should see both of these:
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
Why Google and Jet Brains can't keep this from happening I don't know, but as of today, it cleared the problem right away.

Android Studio 'Obsolete Gradle Dependency' inspection issue

I have following gradle dependencies in my Android build.gradle file.
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
Declared versions are the current latest stable versions of these libraries(android support library). But Android Studio displays following warning on them.
A newer version of exists than 23.2.1 is available:
24.0.0-alpha1
24.0.0-alpha1 seems to be the newly released developer preview and I don't want to take them as a stable version of libraries. I can suppress or disable this inspection and get rid of the warnings. But doing so will avoid valid future warnings as well.
How can git rid of this warning for the developer previews?. The warning should appear only if valid new stable version of the library exists.
I use Android studio 1.5.1Thanks in advance
Guys from Google has already fixed it, so all that you need to do now is to wait for the next update.
This problem has already been reported here:
https://code.google.com/p/android/issues/detail?id=203321

Failed to resolve: com.android.support:appcompat-v7:15.+

i find 2 solutions for this problem, but both didn't work. So i decided to ask you.
I'm using Debian 8 Jessie and Android Studio 1.4
I just created new project and when i tried to start it i got an error:
" Failed to resolve: com.android.support:appcompat-v7:15.+ "
And gives me 3 option.
1) Install Repository and sync project
When i tried it i got an error like this:
Loading SDK information...
Ignoring unknown package filter 'extra-android-m2repository'Warning: The package filter removed all packages. There is nothing to install.
Please consider trying to update again without a package filter.
And down of the window:
Install failed. Please check your network connection and try again. You may continue with creating your project, but it will not complete correctly without the missing components.
2) Show in File
It's my build.gradle dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:15.+'
}
Error in this line:
compile 'com.android.support:appcompat-v7:15.+'
3) Show in Project Structure dialog
Dependencies windows is opened and about this line again:
compile 'com.android.support:appcompat-v7:15.+'
Tried Solutions:
Firstly, i tried to download version sdk again. I deleted Android 4.0.3 and re-download again but still same error.
After that i tried to download support library which recommended in; topic 1 , topic 2. After i download Android Support Library, rev 23.0.1 still got same error.
After that i tried to solve my problem with fixing first option in error (install repository and sync project. And i found some topics again. I checked my HTTP Proxy section in Setting, already "No proxy" is selected.
So, i tried everything i found, but still i got this error. Someone can help me please?
After you downloaded the latest support library with your sdk manager, you can set that version in your gradle file.
If you downloaded 23.0.1 set it like this:
compile 'com.android.support:appcompat-v7:23.0.1'
EDIT:
Also note following hint, given by Android Studio, when using + in Version number:
Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds (com.android.support:appcompat-v7:23.1.+)
Using + in dependencies lets you automatically pick up the latest
available version rather than a specific, named version. However, this
is not recommended; your builds are not repeatable; you may have
tested with a slightly different version than what the build server
used. (Using a dynamic version as the major version number is more
problematic than using it in the minor version position.)
Edit build.gradle
Replace 'com.android.support:appcompat-v7:15.+' with 'com.android.support:appcompat-v7:18.0.0'
Sync It
May be this will help you. If in case this will not work i.e. show error then see for installation of app-compat in "%homepath%\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\appcompat-v7"
Search for the oldest version and put the version number at xx: 'com.android.support:appcompat-v7:xx'
I installed Java and Android Studio today.
When creating my first project with API level 15 as minSDK, I faced the same problem.
As far as I can tell, it seems the installation of the sdk works not pretty well. For me, API level 15 had only the SDK platform. API level 23 had platform and sources. I don't remember, which tools where installed.
To solve the problem, I started the sdk manager (old version), removed api level 15 completely and installed api level 23 as suggested. After that, a newly created project (again with minSDK 15) was properly created.
The difference in the app/build.gradle file is obvious.
Maybe this helps other people facing the same issues, or one of the gurus can further explain, what happened.
Kind Regards
Got same errors.
Mac OSX
V. 10.9.5
Android studio 1.4.1
App:
Before:
android {
compileSdkVersion 15
buildToolsVersion "19.1.0"
After:
android {
compileSdkVersion 23
buildToolsVersion "19.1.0"
Before:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:15.+'
}
After:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.o'
}
Above changes + Build >> Clean Project.
Hope that helps!
Go to Built tab select "Edit Built types" select properties tab and check built tool version it was 19.1.1 for me.
Then go to built.gradle change compile to 'com.android.support:appcompat-v7:19+' . I changed to 19+ because my built version is 19.1.1 ; You have to select according to your built version(18+,19+,20+ like that).
Try following solution:
In Android studio:
Go to File -> Project structure
Check the selected Build Tools Version.
update your build.gradle for app with selected build tools version.
for e.g. 19.1.0
After update, Run Clean.
Please refer below screenshot.[Project Structure-> Build Tools Types][1]
I had a similar error message when creating a project.
fail to resolve com.android.support:appcompat-v7:14.+
I notice that if I create a new project with support for 4.0.3 instead of 4.0, no error occurs. I am using android studio 1.5. Hope this helps.
in my case, support and wearable versions were different, after making them exactly same, gradle build completed successfully.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
provided 'com.google.android.wearable:wearable:1.0.0'
}

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.
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
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

Are all versions of the android support library given the same revision number?

I see that the current revision of the Android Support Library is 21.0.3:
Does that mean that the most recent revision of each version of the support library (v4, v7, v13, etc.) has a revision number of 21.0.3?
In other words if I want to update my build.gradle file to the latest revision, that each version will have that revision number?
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:support-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3' **
** I realized that I only need one of these in my build.gradle file. I'm just showing each to demonstrate my question.
EDIT:
To clarify, I don't just mean right now with the current revision. I mean is this always the case with every revision?
Yes, I believe this is always true. If you inspect the contents of the directory
<path-to-sdk>/extras/android/m2repository/com/android/support/
you can see the available versions of the support libraries (open each subdirectory to view the revision numbers). Mine are all maxed at 21.0.3 right now.

Categories

Resources