Today I noticed that Android API 22 is available so I changed target SDK of my app to 22. When I did that, Gradle started complaining that support libraries cannot have versions lower than the target SDK version.
I checked Support Library revisions link and it does show that version 22 of "v4 support library" and "v7 appcompat library" have been released. So, I bumped up their versions as well in build.gradle file. Gradle then suggested that I install the "Android Support Repository". I had it installed, but I installed it again; and Gradle continued to complain. When I checked ${android_home}/extras/android/m2repository/support-v4 it indeed did not have the version 22.0.0 folder.
I also directly opened the link https://dl.google.com/android/repository/addon.xml which was used by Support Repository installer and it indeed does not list version 22 libraries!
What is wrong here?
After reading your question and the comments again, I understand what you are trying to say. Currently the SDK Manager does not have the Support v22 out.
You CAN download API 22 but you are NOT seeing support-v4. By the way, "${android_home}/extras/android/m2repository/support-v4" is the wrong directory.
The correct directory is: "${android_home}/extras/android/m2repository/com/android/support/support-v4".
Also, you must have it downloaded from your build.gradle, for example:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- You need this
buildToolsVersion '22.0.0' // <-- You need this
defaultConfig {
applicationId 'burrows.apps.example.admob'
minSdkVersion 9
targetSdkVersion 22 // <-- You need this
versionCode 1
versionName '1.0'
}
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = Boolean.valueOf(System.getProperty("pre-dex", "true"))
}
lintOptions {
abortOnError false
}
}
dependencies {
compile project(':Lib-BurrowsApps')
compile 'com.android.support:support-v4:22.0.0' // <-- You need this
compile 'com.google.android.gms:play-services-ads:6.5.87'
}
Source: https://github.com/jaredsburrows/BurrowsAppsExamples/blob/master/Lib-BurrowsApps/build.gradle
Google's m2repository works just like the normal ~/.m2/repository/.
To get the most recent version of the Android support library, I was able to do the following:
Install all the latest things in the SDK Manager
Check what the latest revision is (22.1.0 at the time of this writing)
Update the dependencies section of build.gradle accordingly
build.gradle
dependencies {
...
compile 'com.android.support:support-v4:22.1.+'
}
See also (documentation)
Support Library
Support Library Setup
Support Library Features
Related
Is Android Studio backward compatible with older API?
More specifically,
I need to target API 27 with Android Studio 3.6.3.
I am unable to do so. Why?
Note: I am aware that I would not be able to publish to Play Store. This is not a problem for me.
As stated here - https://developer.android.com/studio/releases/gradle-plugin
Although the Android plugin is typically updated in lock-step with
Android Studio, the plugin (and the rest of the Gradle system) can run
independent of Android Studio and be updated separately.
And in Upgrade Gradle section, in the table
Plugin Version 3.2.0 - 3.2.1 works with Gradle version 4.6+
My set up:
Settings.gradle
distributionUrl=https://services.gradle.org/distributions/gradle-4.9-bin.zip
In apps build.grade:
SDKs/Build tools are set as:
compileSdkVersion 27 buildToolsVersion "27.0.2"
minSdkVersion 27 targetSdkVersion 27
And Dependencies:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.android.support:appcompat-v7:27.1.0' i
implementation 'com.android.support:design:27.1.0'
Build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
But I get the following:
The specified Android SDK Build Tools version (27.0.2) is ignored, as
it is below the minimum supported version (28.0.3) for Android Gradle
Plugin 3.2.1.
Why is that? Surely I was able to target 27 with that plug in version in older versions of AS.
And when I build:
error: failed linking references. (No additional detail in logs)
Note: Trying with even lower versions of Build Tools and Android Gradle Plug Ins (and targeting lower api) gives the same error. Downgrading the gradle version doesn't work either (tried with 4.6)
Note 2: Trying with the latest versions (accepting what AS 3.6.3 gives you by default, which is gradle-5.6.4, buildToolsVersion "29.0.2") gives the below error.
This is easy to reproduce - just create a new project (choose empty activity to reduce dependencies), use legacy support libraries, and change compile and target SDK to 27
.../appcompat-v7-28.0.0/res/values-v28/values-v28.xml:5:5-8:13: AAPT:
error: resource android:attr/dialogCornerRadius not found.
Does it mean you just cannot target anything below 28 with AS 3.6.3? What role would AS play here if the building blocks here are Build Tools and Android Gradle Plug in (as stated above), which I can choose as I please, and yet to no effect?
And just want to note: no, I don't want to update to api 28. I need specifically below 28, and my current version of AS is 3.6.3.
Is there no way out and have to use an older AS? And if the latter, what would then be the role of AS in this?
Tool versions are largely independent of your targetSdkVersion, you don't need buildToolsVersion "27.0.2" for a target sdk of 27
Edit your app's build.gradle to use modern versions of the build tools, and then set targetSdkVersion 27
Note that you will not be able to deploy to the Play Store with this as the minimum target is now 28 (current as of 5/13/2020) source: https://developer.android.com/distribute/best-practices/develop/target-sdk
The following is a portion of a valid app module build.gradle targeting sdk 27
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.mikedg.dekudeals"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
The following is a portion of the buildscript from the project build.gradle that works with it
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
If the above does not work, I recommend looking into migrating to the androidx libraries instead of the old support libraries. https://developer.android.com/jetpack/androidx/migrate#additional_resources
I don't think this should cause problems, but can't confidently say that it wouldn't
I have installed Android Studio 3.1.13 with gradle 4.8.1 and java 1.8.0_171, previously installed. I have installed also the SDK API 22 because I need to test an app in Android 5.1.1
The problem is that the default configuration has compileSdkVersion 28 and I had changed it to 22. I have tried many settings but there are always errors due to the version of android API
My current module build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.company.test"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
}
and the proyect build.gradle is
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I tried to build, the IDE now says
The SDK Build Tools revision (22.0.1) is too low for project ':app'. Minimum required is 25.0.0
Don't know how can I build and test and app for API 22. I'm newbie in Android develpoment. Thanks in advance
As far as I understand your question, the app needs to be tested running on android api level 22 right?
Based on this assumption I would say the most straight forward solution would be to keep every value on default (as long as this worked for you before). Just lower the minSdkVersion to 22.
Short explanation of most important values:
compileSdkVersion 22 : API Level the app is compiled against
buildToolsVersion '22.0.1' : Buildtools Version to compile code (has to match compileSdkVersion)
minSdkVersion 22 : This is the minimum api you want the app running on.
targetSdkVersion 22 : Simply says, you tested your app running on specified API. Google now uses this to determine if your app is up to date to be published in Playstore or not
As emandt already mentioned BUILDTOOLS and gradle should be up to date, as well as targetSdkVersion and compileVersion.
TESTING APP ON API Level:
As long as you compiled your app for a target higher than minSdk you can simply build and install the apk to a device running the requested API level.
The "buildToolsVersion" string should be compatible with the "classpath 'com.android.tools.build:gradle:x:x:x" setting.
You have to lower the second setting until it is accepted.
However I suggest to use latest BUILD TOOLS and latest GRADLE and not revert back to an old ones. Those Tools affect only the Build procedure, not the App itself.
I am using Android 23 build tools,but my imported project support only android 19,how to compact with this or how to fix it.
I see the followinf error in logcat,
"Failed to sync Gradle project 'My Application1'
Error:Error:Cause: failed to find target with hash string 'android-19' in: E:\Android\android-sdk_r24.4.1-windows\android-sdk-windows
Open Android SDK Manager"
This is my build.gradle file"
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
This is my module/build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.appsrox.remindme"
minSdkVersion 7
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Error:Error:Cause: failed to find target with hash string 'android-19'
It happens when the Android-19 sdk is not installed.
Open your SDK Manager and check to see if Android 4.4 (API 19) is installed.
Pay attention using the latest support libraries. The v23.x.x require compileSdk 23
About :
my imported project support only android 19
you should check the difference between compileSdkVersion, minSdkVersion, and targetSdkVersion.
compileSdkVersion is your way to tell Gradle what version of the Android SDK to compile your app with. Using the new Android SDK is a requirement to use any of the new APIs added in that level.
minSdkVersion is the lower bound for your app. The minSdkVersion is one of the signals the Google Play Store uses to determine which of a user’s devices an app can be installed on.
targetSdkVersion is the main way Android provides forward compatibility by not applying behavior changes unless the targetSdkVersion is updated
More info here.
I am using Android Studio 1.2.2 to develop an Android Application. In my build.gradle file, I have defined the compileSdkVersion to 21 since the beginning of the work. Now I wanted to change that to 19, since this software actually will never be installed on an Android device, that runs a higher version than Android 4.4
When I try to change this value to 19, the project does not compile anymore.
After the change of the version value I have:
synced the project
cleaned the project
rebuild the project (tried)
But the following error occurs:
In the file /projectpath/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values-v21/values-v21.xml it marks 103 errors, saying "cannot resolve symbol".
values-v21.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/lmp-mr1-supportlib-release/frameworks/support/v7/appcompat/res/values-v21/styles_base_text.xml -->
<eat-comment/>
<style name="Base.TextAppearance.AppCompat" parent="android:TextAppearance.Material"/>
<style name="Base.TextAppearance.AppCompat.Body1" parent="android:TextAppearance.Material.Body1"/>
<style name="Base.TextAppearance.AppCompat.Body2" parent="android:TextAppearance.Material.Body2"/>
<style name="Base.TextAppearance.AppCompat.Button" parent="android:TextAppearance.Material.Button"/>
....
cannot resovle symbol android:TextAppearance.Material
cannot resovle symbol android:TextAppearance.Material.Body1
cannot resovle symbol android:TextAppearance.Material.Body2
cannot resovle symbol android:TextAppearance.Material.Button
and so on...
What is causing this error? What can I do to make it compile again?
When I change back the compileSdkVersion to 21, everything works normal again.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '23.0.0 rc3'
defaultConfig {
applicationId 'com.appname.id'
minSdkVersion 17
targetSdkVersion 19
versionCode 1
versionName "0.0.2 Alpha"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
to use appcompat-v7:22.2.0 you have to compile against API 21. There's no harm in doing it, even if it will never run on devices running 21.
You can try some older version of the app compat, but then you will be missing in "cool new features" and bug fixes from the latest app compat.
If this might help someone, after MANY trials and errors, I found that I was targeting the wrong SDK version (an older one) in the build.gradle file corresponding to "library". To change this you can do it by hand or go to the Module Settings Menu (right click on your project folder -> Open Module Settings. Then in "library" - Properties you can change the Compile Sdk and the Build Tools Versions
make sure you have installed API 19 in sdk manager
So I know that many other people had this problem, but mine is a little different. I've tried running my app on an LG G2 with Android 4.4.4, and a Note 3 with Android 4.4.2, but neither worked. I have installed the API 18, 19, and 20 SDKs.
Failure [INSTALL_FAILED_OLDER_SDK]
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ween.control"
minSdkVersion 8
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
You can't test an Android-L app on a device with lower API.
Take a look here.
You need to make sure your dependencies are configured targeting the same sdk (also make sure the sdk is supported for the dependency).
As of version .11, the gradle plugin now uses the new manifest merger tool by default which you can use to avoid conflicting configurations when merging manifests from your dependencies while building by specifying <uses-sdk tools:node="replace" /> in your AndroidManifest.xml file.
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
credit goes to Eddie Ringle
I was having a similar issue but my device sdk was 19 and it was looking for it to be 20. I changed the sdk from the file > Project Structure > SDK to 19 also I noticed when I was running it had the wear value selected in the top toolbar so I switched that to mobile and Voila.