Gradle not picking right appcompat-v7:22.2.1 - android

I am facing a strange issue, i installed latest appcompat-v7:23.0.0
Where as i got to know i must not need it but i need to go with appcompat-v7:22.2.1 or appcompat-v7:22.0.0
I updated my gradle as per my needs but it always pickup appcompat-v7:23.0.0 which is not required, any one guide me how can i resolve this issue?

Since you are using
compile 'com.google.android.gms:play-services:+'
you are using the latest version compile 'com.google.android.gms:play-services:8.4.0' which has a dependency with support libraries v23.
You have to compile with API 23.
Change this line:
compileSdkVersion 23
If you don't want to use the api23 you can use a specific version like as
compile 'com.google.android.gms:play-services:7.8.0'
In general is not a good practice the use of + in your dependencies because you can't replicate the build in the future with the same libraries and you don't know which version you are using.
Also you can use api23 with Httpclient.
Just use:
android {
useLibrary 'org.apache.http.legacy'
}
More info here.
The useLibrary requires the gradle plugin 1.3.0 (classpath 'com.android.tools.build:gradle:1.3.0') or higher.

AppCompat (aka ActionBarCompat) started out as a backport of the
Android 4.0 ActionBar API for devices running on Gingerbread,
providing a common API layer on top of the backported implementation
and the framework implementation. AppCompat v21 delivers an API and
feature-set that is up-to-date with Android 5.0
You can use
compile 'com.android.support:appcompat-v7:22.0.1'
Finally
android {
compileSdkVersion 22
buildToolsVersion '22.0.1' // You can set buildToolsVersion '23.0.1'
Advice
You should use
compile 'com.google.android.gms:play-services:7.8.0' // or 8.4.0
Good Approach : Use latest Version .
you need to download the latest support repository from internal SDK
manager of Android Studio or from the stand alone SDK manager. Then
you can add compile 'com.android.support:appcompat-v7:23.0.1'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId ""
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0' // or 8.4.0
}
Edit
You can use this classpath
classpath 'com.android.tools.build:gradle:1.3.0'
Then Clean-Rebuild-Restart-Sync your project . Hope this helps .

Related

Where is Android Studio reading the build tools version?

I'm getting the error:
WARN - ect.sync.idea.ProjectSetUpTask - Failed to find Build Tools revision 26.0.2
It is actually an error breaking my build but this wasn't copyable so I found this line in the log (the only place I could find reference to "26.0.2"
I've searched (Ctrl-Shift-F) for 26.0.2 everywhere and found just 2 occurrences of 26 in one file, the "app" level build.gradle:
android {
compileSdkVersion 26
defaultConfig {
targetSdkVersion 26
...
Which I changed to 27, my build tools is 27.0.3 which I use for other projects, I don't want another build tools. How can I communicate this to Android Studio?
Credit to https://stackoverflow.com/a/47425748/866333, I hope this offers easier sign posting:
android {
compileSdkVersion 27
// Add the following line, Android Studio is quite good for filtering bloat.
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
...
I actually had to add a line, so I don't know where AS was reading 26.0.2 from, but this fix has worked on 2 of my projects. Oh, and because I'm now using the support lib (because its 2018):
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
will be on the wrong versions, fix by replacing the 3 occurrences of "26.1.0" with, eg, "27.1.1", as that was what the error messages was hinting at.

Please explain gradle dependancies vs min build sdk

Android beginner here...
I'm getting all sort of rendering errors, and eventually concluded it's got something to do with my gradle dependencies.
Now I found a nice tutorial which I've been following, http://www.android4devs.com/2015/06/navigation-view-material-design-support.html but I'm running to a problem extending it further, and there is something I don't think I understand.
Should I not be using the latest stable version of any library I can? Surely these libraries are backwards compatible?
If I am supposed to use the older version of library, to match the compile sdk (which I understand to mean I'm compiling for backwards compatibility, and supporting, say, lollipop API 21-22) then:
I would need a place to see a complete list of all versions of all libraries (which I cannot find), and
I would not be able to use new features like RecyclerView which only came in at Marshmallow API 23.
Am I missing something?
build.gradle (module app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.myFirstApp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
...
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
Error message
The support library should not use a different version (26) than the compile sdk version (22).
You are using
compileSdkVersion 22
and
compile 'com.android.support:appcompat-v7:26.1.0'
error you are getting is because you are using compat version 26 while compileSdkversion is 22
You should update to compileSdkVersion to 26 and android studio will download required files so that your error will be removed. If you cannot update your compilesdk version to 26. Then change support library version to 22.2.1
compile 'com.android.support:appcompat-v7:22.2.1'
Got list of support libraries from link
https://developer.android.com/topic/libraries/support-library/rev-archive.html
and
https://developer.android.com/topic/libraries/support-library/revisions.html

Changing minsdk version in android studio to enable use of RecyclerView

I am new to android development, and just learning. I am trying to create something with a RecyclerView, and the tutorial tells me I have to add these Gradle dependencies to my app's module:
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
When adding them to the build.gradle file, I get an error saying I have an incompatible compileSdkVersion. I changed compileSdkVersion 24 to compileSdkVersion 21 but the error doesn't go, and I get an error on these:
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
These are the rest of the settings that seem applicable to the sdk version in that file. Do I need to change any of those also in order to it to be compatible?
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "uk.ac.ncl.legacymakingv4"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
You should always use the same version of everything in the com.android.support group. Therefore change your cardview and recyclerview to use the same 24.0.0 version.

downgrading from sdk 23 to 22 android

I decided to reduce my api level from 23 to 22. To begin with, I downloaded android studio with the latest 23 API installed. I installed the 22 API now but I don't know if I installed the other stuff like:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
Can't find where to look if these are installed... So this is how my manifest looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 //changed this, used to be 23
buildToolsVersion "22.0.0" //changed this also, but I don't know if it's installed....
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 22
versionCode 11
versionName "2.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'libs'] } }
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.twitter.sdk.android:tweet-composer:1.0.2#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'//changed this also, but I don't know if it's installed....
compile 'com.android.support:design:22.2.0'//changed this also, but I don't know if it's installed....
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services-identity:8.4.0'
}
So when I try to sync it gives me this crap:
C:\Users\jonathan\AndroidStudioProjects\TrashOmeter\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\jonathan\AppData\Local\Android\sdk\build-tools\22.0.0\aapt.exe'' finished with non-zero exit value 1
How do I get it to compile with 22 sdk correctly???
You wont be able to downgrade from SDK 23 to 22 if have already uploaded your apk (sdk 23) on google play. Store will not let you.
I have already done this mistake and now my APP is disadvantaged compared to my competitors who didnt made this mistake.
So DONT USE SDK 23, it will make your users angry if they have to enable LOCATION for your app (access to wifi channel list is main purpose of my app)
I decided to reduce my api level from 23 to 22
Given the comments in your build.gradle file, you appear to mean that you reduced your compileSdkVersion to 22.
I have no idea why you would do that.
Raising the compileSdkVersion to a newer level is perfectly reasonable and will be required to use some newer versions of dependencies (let alone any new references from your own code). I know of no problems in modern Android development that are solved by reducing compileSdkVersion. You seem to be causing yourself pain for no actual benefit.
I installed the 22 API now but I don't know if I installed the other stuff like
If you have an up-to-date "Android Repository" in the SDK Manager, then you have older versions of the Android Support libraries.
//changed this also, but I don't know if it's installed...
If you have an up-to-date "Build Tools" in the SDK Manager, then you have older versions of the Android Support libraries.
So when I try to sync it gives me this crap:
That "crap" is because you decided to change your compileSdkVersion to 22, yet not change your dependencies to similarly older versions. Your current dependency versions are written with references to things from API Level 23 (in this case, resources) and need compileSdkVersion 23.
How do I get it to compile with 22 sdk correctly?
Reduce the versions of your dependencies to ones that pre-date the existence of API Level 23. For those that you are getting from Maven Central or JCenter (e.g., facebook-android-sdk), you can probably find out dates of artifacts from their Web interface, and try to find ones from August 2015 or earlier. For the rest... you're on your own.
Or, change your compileSdkVersion back to 23.
So thanks to CommonsWare I found the answer. I had to change the google play dependency to a lower version. So in gradle I changed:
From:
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
To:
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.google.android.gms:play-services-identity:7.3.0'

Android appcompat v7:23

Today, Google released SDK 6 API 23+.
I tried to create a project with the API 23, but I'm having the following problem:
Failed to resolve: com.android.support:appcompat-v7:23.0
Here's my gradle file:
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "my.package"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:23.0'
compile 'com.google.android.gms:play-services:7.8.0'
}
In the SDK manager, the version 23 isn't listed to update:
How can I solve this?
Original answer:
I too tried to change the support library to "23". When I changed the targetSdkVersion to 23, Android Studio reported the following error:
This support library should not use a lower version (22) than the targetSdkVersion (23)
I simply changed:
compile 'com.android.support:appcompat-v7:23.0.0'
to
compile 'com.android.support:appcompat-v7:+'
Although this fixed my issue, you should not use dynamic versions. After a few hours the new support repository was available and it is currently 23.0.1.
Pro tip:
You can use double quotes and create a ${supportLibVersion} variable for simplicity. Example:
ext {
supportLibVersion = '23.1.1'
}
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:palette-v7:${supportLibVersion}"
compile "com.android.support:customtabs:${supportLibVersion}"
compile "com.android.support:gridlayout-v7:${supportLibVersion}"
source: https://twitter.com/manidesto/status/669195097947377664
As seen in the revision column of the Android SDK Manager, the latest published version of the Support Library is 22.2.1. You'll have to wait until 23.0.0 is published.
Edit: API 23 is already published. So u can use 23.0.0
Ran into a similar issue using React Native
> Could not find com.android.support:appcompat-v7:23.0.1.
the Support Libraries are Local Maven repository for Support Libraries
First you need to download the latest support repository (17 by the time I write this) from internal SDK manager of Android Studio or from the stand alone SDK manager. Then you can add compile 'com.android.support:appcompat-v7:23.0.0' or any other support library you want to your build.gradle file. (Don't forget the last .0)
Latest published version of the Support Library is 24.1.1, So you can use it like this,
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
Same as for other support components.
You can see the revisions here,
https://developer.android.com/topic/libraries/support-library/revisions.html

Categories

Resources