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.
Related
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.ta2323.ftsm.lab_recyclerview_a160158"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
}
Can someone help me? Im not sure what to use and im confuse to use which version. Can someone explain more detail?
This is my coding in build gradle.
compileSdkVersion
The compileSdkVersion property specifies the compilation target.
The latest target sdk version is 26 so use compile sdk version 26.
The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.
See more here
Use the compile SDK version the same as the prefix of build tools version. And always go for the latest one. So use 26 for now.
You should always use the same version for the following in your build.gradle:
compileSdkVersion
buildToolsVersion
targetSdkVersion
Support library
Because you set the support library and buildToolsVersion to version 26, then you need to stick with 26 for all the above list. This is because when using buildToolsVersion "26.0.1" you're specifying the build tools for API 26. So, you need to change your build.gradle to something like this (read the comment):
apply plugin: 'com.android.application'
android {
/**
* compileSdkVersion specifies the Android API level Gradle should use to
* compile your app. This means your app can use the API features included in
* this API level and lower.
*/
compileSdkVersion 26
/**
* buildToolsVersion specifies the version of the SDK build tools, command-line
* utilities, and compiler that Gradle should use to build your app. You need to
* download the build tools using the SDK Manager.
*
* If you're using Android plugin 3.0.0 or higher, this property is optional—
* the plugin uses the minimum required version of the build tools by default.
*/
buildToolsVersion "26.0.2"
defaultConfig {
// Defines the minimum API level required to run the app.
minSdkVersion 15
// Specifies the API level used to test the app.
targetSdkVersion 26
...
}
}
dependencies {
...
// NEVER USE ALPHA Version in your dependencies.
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:recyclerview-v726.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
}
Read more at Configure Your Build
My app is compilesdkversion is 23 i have to upgrade to 24 and all support libraries to 24 while upgrading the recyclerview in the app is not displaying views in a module. is there a particular change log for the issue, Suggest a solution Thanks in advance
Due to security reason i cant give my entire gradle file
/* android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 16
targetSdkVersion 23
......
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'*/
You need to set the layout_height to "wrap_content" for the recyclerview items.I got the same problem,the mentioned solution resolved the issue.
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 .
I have recently updated android studio which brought me many problems.
whenever I create a new android project the gradle scripts(Module:app) is displaying the below code
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.listproject"
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'])
compile 'com.android.support:appcompat-v7:23.+'
}
here the above compiledsdkversion 23 provides me
Error:Failed to find: com.android.support:appcompat-v7:23.+ Open
File:open.dependency.in.project.structure">Open in Project Structure
dialog
Because before upgrading I had compiledsdkversion as 21 and it does not provide any problem in gradle sync task.
But when I manually modified the compiledsdkversion to 21 it worked correctly.But every time when I create a new project it has been set to 23.Is there any way to make 21 as default or any corrections for compiledsdkversion 23 itself.
I have another doubt before upgradation my restful services projects worked correctly after this upgradation I am facing many problems.
Even HelloWorld application is not running.But if I manually change the compiledsdkversion to 21 everything is fine.Please provide me a solution for making the compiledsdkversion to 21 by default.
> compile 'com.android.support:appcompat-v7:23.+'
The "+" in "v7:23.+" means to take the newest "v7:23" version. If you have no internetconnection this fails.
either reestablish an internetconnection while building or replace the package with a fixed versionnumber that your system has locally cached when there was an internet conntection (i.e. com.android.support:appcompat-v7:23.0.1)
You are using the appcompat (and other support libraries) v23, please compile your project with API 23.
Change in your build.gradle the compileSdkVersion to 23
I am getting multiple errors in my project, previously it was working fine. I tried may things changing the target api changing dependencies, i dont know why it is not working. Please help me out.
Change your build.gradle file to this,
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.name"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
.......
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:6.5.87'
}
Now clean and rebuild the project.