my compileSDKversion is 26, so i want to add some support libraries into the app build.gradel such as implementation 'com.android.support:card-v7:26.x.x'.
How do i choose the right version for my current compileSDK version?
I just did "try and fail". I mean, i type x=1 then running "sync project with gradle", and wait for the IDE notifies it runs fine. But i don't know what exactly appropriate version i should use. I did search, i found some people tell the version of support library basing on compileSDKversion, and should use the last 'compileSDKVersion', but that doesn't solve my problem.
This https://developer.android.com/topic/libraries/support-library/setup can help you to setup a support librairy.
I think in your case card is cardview. Because I don't find card when I try sync.
This is an exemple of what I suggest for sdk 26
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
...
targetSdkVersion 26
...
}
...
}
dependencies {
...
implementation 'com.android.support:cardview-v7:26.1.0'
...
}
Related
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.
Recently I've been getting this problem.
As far as I know, there is no 26.X.X versions of these support libraries, what does Gradle wants from me?
After reviewing a previous question, you may want to be sure that your compileSdkVersion matches across the board, if you want to build in 25 but you are in 23.
This support library should not use a different version Error in build.gradle
You can confirm versions by >> Create new project in Android studio >> Press Ctrl+Shift+Alt+S >> Proceed to 'Project' section >> You can see actual gradle version and android pluging version. Copy that to your project.
The problem lies in your Compile version in build.gradle file.
It seems, your compile version is 26.
Please change your compile version to 25 and sync gradle.
compileSdkVersion 25
buildToolsVersion "25.0.3"
Please set your Compile Version to 25
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.user.xxxxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
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'm trying to use the new CardView from Android L. I updated everything in the SDK manager, but I keep getting the following error:
Failure [INSTALL_FAILED_OLDER_SDK]
This is my build.gradle file:
apply plugin: 'android'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "www.thomascbeerten.com.nieuwetests"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// Support Libraries
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile 'com.android.support:mediarouter-v7:19.1.0'
// compile 'com.android.support:support-v13:19.1.0'
compile 'com.android.support:recyclerview-v7:+'
}
Recently there was a post here regarding the L SDK's incompatibility
with prior versions of Android. I've been digging in AOSP repositories
for quite a few hours now, and determined that the tools behave this
way because they are designed to treat preview platforms differently.
If you compile against a preview SDK (android-L), the build tools will
lock minSdkVersion and targetSdkVersion to that same API level. This
results in the produced application being unable to be installed on
devices running older releases of Android, even if your application
isn't doing anything specific to L. To make matters worse, the new
support libs (CardView, RecyclerView, Palette, etc.) are also locked
into the L API level, even though--according to their repository
names--they should work on API level 7 just fine (and they do!).
See my Reddit post about this here, with a workaround.
Once you have the above issues resolved as mentioned by Eddie. You might also run into another error;;
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
This will be present in your styles.xml . The quick fix is to replace it with the following below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--<style name="AppTheme" parent="android:Theme.Material.Light">-->
<style name="AppTheme" parent="android:Theme.Holo.Light">
</style>
Change
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
to
android {
compileSdkVersion 21
buildToolsVersion '21.0.2'
Note android-L is in single quotes but 21 isn't. 21 is an integer and not a string.
When you compile with L it actually makes a change during compilation setting your minsdkversion to L. If you want to use RecyclerView or CardView I would recommend checking out RecyclerViewLib. RecyclerView and CardView have been moving into this library so that there is no min version L problem. The author also explained in his blog post how all L related code was removed to make it safe to use.
To add RecyclerViewLb to your project just add the following line to your dependencies in your build.gradle file:
compile 'com.twotoasters.RecyclerViewLib:library:1.0.+#aar'
You then do not want to add the compile 'com.android.support:recyclerview-v7:+' to your build.gradle as you will get that through RecyclerViewLib.
I just ran into this problem. This can happen when your min sdk version and built targets are set to a higher API level/OS version than your phone is running. If you're using Android Studio, go to File > Project Structure > and edit relavent settings then Run again.
I am experiencing issues with creating a project that uses google play services in Android Studio. I am able to import com.google.android.gms, but nothing else. after I hit . after gms, I get the options of importing * or R. There is no option for GoogleMap, GooglePlayServicesUtil, etc.
I have tried quite a few different things, and have scrapped the project multiple times and started from scratch. At first I attempted to import the google-play-services_lib as a module into the project, but that did nothing, and after reading for a while I found that this was the incorrect way to do it.
I have since tried this (which seems to be the correct way) but it still is not working.
Code from Gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
}
dependencies {
compile 'com.google.android.gms:play-services:3.2.65'
}
As I mentioned, I do not have any error with the compile line. In fact, 'intellisense' detects com.google.android.gms. Just nothing after that, so I can't import anything useful.
Any help would be greatly appreciated. I have been banging my head against a wall with this. It would help to have a fresh set of eyes.
Thanks!
It needs to Sync project with gradle files everytime you edit build.gradle so AndroidStudio can fetch the changes.
Note, that your build tools are outdated:
android {
buildToolsVersion "18.1.1"
}
Google Play services Integration.
Step 1:
SDK manager->Tools Update this
1.Google play services
2.Android Support Repository
Step 2:
chance in build.gradle
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.0.+'
}
Step 3:
android.manifest.xml
<uses-sdk
android:minSdkVersion="8" />
Step 4:
Sync project file with grandle.
wait for few minute.
Step 5:
File->Project Structure find error with red bulb images,click on go to add dependencies select your app module.
Save
Please put comment if you have require help.
Happy coding.