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

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.

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.

How to get "CompileSdkversion" programmatically in Android

I have an About box in my App that displays information about the App, the phone and the data it uses. It's very useful when a user has a problem. I can get the phone's SDK version using "android.os.Build.VERSION.SDK_INT". However, I haven't found a way to get the value of "CompileSdkversion" which indicates the SDK version the App was compiled with. This is the value that is set in the build.gradle file.
While the Android OS version varies by user, the compileSdkVersion does not. For version X.Y.Z of your app, the compileSdkVersion is whatever you said it was when you compiled that app version. So long as your about box contains the app version, you know what compileSdkVersion that you used, if you keep track of that (e.g., check what it was in your version control system).
But, if you really want to have it be available to you at runtime, you have two options.
If your minSdkVersion is 31 or higher, you can use compileSdkVersion on ApplicationInfo. However, most likely, if you are reading this before the year 2026, your minSdkVersion is lower than that.
For older devices than Android 12, you could add a BuildConfig field for it, at least with newer versions of the Android Gradle Plugin:
android {
compileSdk 31
defaultConfig {
applicationId "com.commonsware.android.myapplication"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "int", "COMPILE_SDK_VERSION", "$compileSdk"
}
// other stuff goes here
}
This takes your defined value for compileSdk and hoists it into BuildConfig.COMPILE_SDK_VERSION, so you can reference it at runtime. This was tested using a scrap Arctic Fox project, using Gradle 7.0.2 and 7.0.3 of the Android Gradle Plugin.
Here is the relationship between the three values:
minSdkVersion (lowest possible) <=
targetSdkVersion == compileSdkVersion (latest SDK)
CompileSdkVersion has nothing to do with what devices can and cannot run your app. Usually, you set this to be the latest version of the Android SDK.
And the targetSdkVersion should be fully tested and less or equal to compileSdkVersion.(It depends on your app)
If you are using the features of API level of 26 then you need to use compileSdkVersion 26, the lower version will give you an error.
Android supports backward compatibility
(i.e. an app compiled on 26 can also run on a phone having API level 26 or lower).
Considering your use-case, wouldn't a better approach be just to show the current app version? If you know the version, you could look up how/when it was created (via git tags, for example) and then find out the SDK version it was compiled with.

Androidx min sdk

What is androidx min sdk? I just migrated to androidx and i need to support minsdk 14. But my build fails indicating that androidx.browser:browser:1.0.0 has minsdk 15.
I can't find it in release notes or anywhere else
androidx.browser:browser:1.0.0 requires the minSdk = 15 (see) in order to function properly, so generally theres no way to support minSdk = 14 while still using androidx.browser:browser:1.0.0.
So basically you have these options:
a. Set minSdkVersion to 15 in app level build.gradle file(and stop supporting minSdkVersion 14)
However if u 'must' have to support minSdkVersion 14 :
b. You can add this line in AndroidManifest.xml file just before application tag:
<uses-sdk tools:overrideLibrary="androidx.browser"/>
this will ensure the project will run properly in most cases but it might lead to run time crashes in few occasions.If you are not really using some feature of the class that absolutely requires sdkVersion 15 then u might just get lucky.
c. Look for alternative classes that can do similar behaviour with minSdkVersion 14 (this might be extremely unlikely)
d. You can consider reverting back to android support libraries instead of androidx. Since, android support libraries will continue to stay around in the google's maven repo for a while.
As stated here:
Starting with Support Library release 26.0.0 (July 2017), the minimum supported API level across most support libraries has increased to Android 4.0 (API level 14) for most library packages.
AndroidX has started with the support library for API Level 28, so minSdk 14 will be the requirement.
For your artifact, the current stable version requires minSdk 15 and the current latest alpha release (1.2.0-alpha09) requires minSdk 16.
AndroidX browser is afaik a replacement / androidX version of Chrome Custom Tabs which had required minSdk 16, maybe this explains the sdk requirement.
By the way you can find the release notes here.

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