What should i set for my compileSdkVersion? - android

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

Related

Problems updating new version 10.2.0 of PlayServices and Firebase

I develop an Android app using Android Studio and I got the message today that there is a new version of Google Play services and Firebase.
From 10.0.1 to 10.2.0.
I'm using Google play services analytics and ads that's all.
I am already choose an API min 9 and Now I think the ads can't be show in API < 14 .
My build.gradle File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.ilyo.x1application"
minSdkVersion 9
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Error Message
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library
[com.google.firebase:firebase-ads:10.2.0]
/Users/mac/Documents/AndroidStudioProjects/Project1/app/build/intermediates/exploded-aar/com.google.firebase/firebase-ads/10.2.0/AndroidManifest.xml
Suggestion: use
tools:overrideLibrary="com.google.firebase.firebase_ads" to force
usage
I want to all my ads of my Application can show in all devices, What do you recommend ?
The 10.2.0 version of ALL google related services require a minimum of API version 14. This is a choice done by Google, so they don't have to support API versions below 14.
So you'll have to stick to version 10.0.1 forever if you want to support API versions below 14. Or, you will have to raise your apps minimum API version to 14, and then use the new google services.
Article: https://www.xda-developers.com/google-play-services-release-notes-are-available-for-the-10-2-update-bye-gingerbread/
Here you can find the official blog post by Google.
Version 10.0.0 of the Google Play services client libraries, as well as the Firebase client libraries for Android, will be the last version of these libraries that support Android API level 9 (Android 2.3, Gingerbread). The next scheduled release of these libraries, version 10.2.0, will increase the minimum supported API level from 9 to 14.
Since you are using:
minSdkVersion 9
you have to change it with:
minSdkVersion 14
Otherwise you can build multiple APKs to support devices with an API level less than 14 using:
productFlavors {
legacy {
minSdkVersion 9
}
current {
minSdkVersion 14
}
}
dependencies {
legacyCompile 'com.google.android.gms:play-services:10.0.0'
currentCompile 'com.google.android.gms:play-services:10.2.0'
}

The SDK platform-tools version (24.0.1) is too old to check APIs compiled with API 25; please update [duplicate]

This question already has answers here:
The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25; please update
(9 answers)
Closed 5 years ago.
I am getting this error but I have already downloaded the missing components for the API 25 and changed the gradle file to the code bellow. I already Sync everything and it gave me 0 errors but I still get this message bellow the package name on each file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25'
defaultConfig {
applicationId 'foodlebeeapp.com.foodlebeeapp'
minSdkVersion 16
targetSdkVersion 25
versionCode 7
versionName "1.3"
multiDexEnabled true
}
repositories {
mavenCentral()
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.support:design:25.0.1'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'ch.acra:acra:4.9.0'
compile('de.keyboardsurfer.android.widget:crouton:1.8.4#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile project(':volley')
compile project(':payUMoneysdk')
compile('com.mikepenz:materialdrawer:5.4.0#aar') {
transitive = true
}
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.urbanairship.android:urbanairship-sdk:8.2.4'
compile 'com.android.support:cardview-v7:25.0.1'
}
apply plugin: 'com.google.gms.google-services'
The full report is:
You need to update your SDK platform tools.
1 - Launch SDK Manager
2 - Go to SDK Tools or Launch Standalone SDK Manager
3 - You will see "Update available" ahead of SDK platform tools & SDK tools
4 - Select these components to update
Update the build tools by going to SDK Manager and find the build tools there. Update them.
If still exists go to Help-> update and check for updates and update to the latest version.
Restart android studio and everything should be set fine
You have to download/Update the api 25.
build.gradle file
minSdkVersion = 19
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = "25"
supportLibraryVersion = "25.0.0"

Android Studio Build.Gradle Sync Error

I am experiencing a problem building my application in Android Studio. I am using Android Studio 2.2 Preview 7. When I start up my Android Studio it gives an error:
The plugin is too old, please update to a more recent version, or set
ANDROID_DAILY_OVERRIDE environment variable to xxxxxxx.
It requests I fix plugin version and sync project. I have made all the required updates but the error remains. I have read similar questions on the issue but they don't seem to apply to my case.
Could you please assist in providing me with a working solution?
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mobileappdev.novarttech.sunshine"
minSdkVersion 10
targetSdkVersion 23
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
compile 'com.android.support:design:23.3.0'
testCompile 'junit:junit:4.12'
}
As per my observation it seems like you haven't updated Android SDK platform to version 25. First of all download and install android sdk platform and build tools from SDK Manager and use the following lines in your build.gradle(module app)
compileSdkVersion 25
buildToolsVersion "25.0.0"
Also update dependencies according to that. It should work then
As #claudio-redi says, you need to upgrade your build gradle tools.
Use build tools 2.2.2 to your root build.gradle:
classpath 'com.android.tools.build:gradle:2.2.2'
And change the gradle distribution to 2.14.1 in gradle/wrapper/gradle-wrapper.properties file with:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Or if you already have download the gradle distribution and place it in a directory, you can set it in your Android Studio from menu File->Setting->Gradle and set it as the following image:
Please be noted when you want to use API Level 25 you need to make sure that compileSdkVersion, buildToolsVersion, targetSdkVersion, and Support Library using the same API Level 25.

What is Android N and why does it think I'm building with it? (Android Studio 2.1.2, Windows 7)

I started a new generic Android project and I'm getting an error in the Design View saying "Android N requires the IDE to be running with Java 1.8 or later".
But earlier Gradle complained: Error:(3, 22) compileSdkVersion android-23 requires compiling with JDK 7 so I installed JDK 7 - 1.7.0_79 and that fixed the Gradle problems. I don't really want to go to JDK 8.
So what is Android N ? My understanding is that it's the "next" or "latest" version of Android, but I don't need that for my work. I just need to support CalendarView and NestedScrollView. Where am I telling it that I need "Android N", and how do I change that?
My Build.Gradle says:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.ags.mycalendarviewapp"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
}
...
So what is Android N ?
It is the next version of Android, API Level 24. The tasty treat is Nougat.
(no, really, that's the name)
Where am I telling it that I need "Android N", and how do I change that?
If you are getting that in the design view, that's the version of Android that is being used for the preview. It defaults to the latest version whose SDK bits you have installed.
To change it, switch it in the bugdroid drop-down on the right side of the design view toolbar:

Android API level - gradle compiles - will it run?

I changed the API level in my android project for test purposes from 22 down to 7 in the build.gradle file.
Gradle has no problems to build the project and it runs on my (Android 5.1 OS) withouth problems.
Does the successfull build indicates the app would run without problems on lower OS (down to API level 7)? If not - how can I check which API is the lowest appropriate for my application?
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myapplication"
minSdkVersion 7
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
The Gradle tooling, especially Lint, is nowadays very good to figure out whether or not your minSdkVersion really works for your app and will usually block a release build in the lintVitalRelease task when you use API that is not available on your min SDK level.
And of course, you always could (and should) create an API level 7 emulator and test-drive your app there as well. Even if it does not crash right away, some things might behave weird / different or might plainly be not working or visible at all, because compat API calls you were using have been converted to noops on lower API levels.

Categories

Resources