TargetSdkVersion in library grater then targetSdkVersion in application - android

I have an Android application with targetSdkVersion = 26 and compileSdkVersion = 26. Is it possible to work fine when I use a library (use gradle dependencies) with target targetSdkVersion = 28 and compileSdkVersion = 28 ? Or it is requre to update target and compile versions in application like in library? Is target and compile versions should be the same? Is target and compile version should be 28 to migrate to AndroidX? Is AndroidX can be use with version 26?

Target SDK version:
The targetSdkVersion value tells Android which API level your app was designed to run on. Keep this to the latest version.
Compile SDK:
version, or build target, specifies which version to use when building your own code. When Android
Studio is looking to find the classes and methods you refer to in your imports, the build target
determines which SDK version it checks against.
You should update the target and compile sdk to 28 in order to use the new library

Related

How do I solve this error in Android Studio

6 issues were found when checking AAR metadata:
Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency 'androidx.activity:activity:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency 'androidx.core:core:1.9.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency 'androidx.core:core-ktx:1.9.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion
of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
I was trying to run a code
Upgrade your compile Sdk and target Sdk 32 to 33 Or change your 'androidx.appcompat:appcompat' library version from 1.6.0 to 1.5.1.
In your project directory go to :
Gradle Scripts > build.gradle(Module : ___)
android {
compileSdk 32 **(-> Change 32 to 33)**
...
}

Xml Suggestions not getting after change compileSdk & targetSdk to 33

I am getting some issue while updating compilesdk and targetsdk to 33.
And if I set compilesdk or targetsdk to 32, 31 or less, I get another library support issue during compilation, as described below...
1. Dependency 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.0-alpha02' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.1 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
and getting this same issue with all newly added library to the gradle
I'm not sure if this is a sdk 33 or library issue.
I already tried this--->https://stackoverflow.com/questions/30684613/android-studio-xml-editor-autocomplete-not-working-with-support-libraries/54007742#54007742
Please Refer this link. There is issue in Android Studio Chipmunk Version. Google Team fixed in Android Studio Dolphin. Check Issue Tracker as well
Replace
def lifecycle_version = "2.6.0-alpha02"
with
def lifecycle_version = "2.4.0-rc01"
in build.gradle(app) file.
Please refer to this link for screenshot.

Can I use Navigate Compose whilst still Compiling for a Minimum SDK of 21?

I'm having some trouble getting my app to compile whilst using Navigate-Compose, is it currently possible to produce apps for an SDK this low, or should I increase my minimum SDK?
Set the compileSdk version to 31 in your gradle.build file, such has this:
android {
compileSdk 31
defaultConfig {
.....
Note that this won't affect the target minimum SDK version, that can still be as low as 21, it is just the version it will be compiled with.

Best way to update Support Library

Till now(30-Nov-2017) google has released android support lib version 27.0.2 and Android Api version 27(Preview). Right now my application have Target version 25 , Build tool version 25.0.3 and Compile sdk version 25. I am planning to update my Support Lib as well as Compile sdk version to 26. So my questions are
1. Is Support lib version is related to android Api version means I am not updating android api to 27 because it is in preview so should I uses support lib 26.x.x or 27.x.x(which is latest).
2. which build tool version should i use means
Go for API level 26. Because API 27 is in preview mode so it won't be stable for now. Change your Build.gradle file like this and sync you are good to go.
android {
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
applicationId "Your app ID"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
And you will have to update your dependencies too because they won't work in latest versions if you use the old ones. So that's why supp lib is related to android API.
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'
Answer to your 2nd question : You can use latest build tool version 27.0.1
buildToolsVersion '27.0.1'
You first need to download it from sdk.

How to make imported projects use older api level?

I have a relatively old android device that works under api level 15, and I want to make some simple programs for it. Right now I just watch examples. I'm importing them from the sdk/samples/android-15 directory via the import command, they are imported as android-21 projects, then I go to module config and change api level to 15. This seemed to long for me, so I tried to fix it by deleting all sdk except 15. Now it doesn't import at all.
Where I can tell android studio to use sdk 15?
You dont need to change anything in the module configuration.
Go to your build.gradle file and check the next:
compileSdkVersion 21 //the version of the API the app is compiled against
buildToolsVersion "21.1.2"
defaultConfig {
// put here the minimum Api version compatible, in your case 15 or lower
minSdkVersion 15
targetSdkVersion 21
}
dependencies {
//be sure you add the dependencies with the support library
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
}
have you enabled the developer options in your device?
http://developer.android.com/tools/device.html
SDK manager: Check out that you didn't delete the minimun sdk tools required:
http://developer.android.com/sdk/installing/adding-packages.html
You dont need to download all the api version abailable, those are

Categories

Resources