Getting minimum SDK and target device - android

How come starting a new project on android studio 2.2.3 doesn't let you choose minimum sdk or target devices anymore? It used to and now when you hit create new project after naming it it takes you directly to the project.

Even after it has taken you to the project, you can change it from the build.gradle file.
There are two build.gradle files. One at the app level and another at the project level.
Open the app level build.gradle and you'll be able to see targetSDK and minimumSDK options. You can alter them there.

Related

Changing (lowering) minSDK (API level) for Android Studio (2020+)

How can I change the minimum SDK in an Android (Studio) project with recent (2020+) versions of Android Studio and Gradle?
During the creation of a new Android Studio project the wizard ask for the minimum SDK required.
Since the wizard generates a lot of boilerplate files and code, I assume that the boilerplate code is tailored to the minimum SDK chosen. My first objective is to generate a modern, lean, forward-compatible (Kotlin) app, so I chose API 31 (most recent non-beta on 29 Dec 2021). However, once the app (which is simple) is working, I would like to lower the minimum SDK to include as many devices as possible (without adding legacy dependencies, code, etc.). Is this a correct way to think about the relation between the choice of minimum SDK and the boilerplate code?
There are existing questions on older (2013) versions of Android Studio (and Gradle), e.g. here, but these do not work in modern versions of Android Studio and Gradle (I have only one build.gradle file and it does not mention any SDK, adding this gives errors).
EDIT: see below an image of the folder tree, as suggested.
I believe all you need to do is set minSdkVersion like provided by this answer. The problems you may encounter are going to be massively different based on what you're going to be doing, but mostly it should be OK. Of course, more you lower minSdkVersion, the more problems you will encounter, but it should be mostly ok to at least version 23.
However, minSdkVersion is usually chosen at the beginning. You should probably set it to 21 (which covers 98% of devices) and start from there (industry standard is currently at 23, which covers 94.1% of devices).
You should not be afraid of the app not being forward compatible because changes are usually quite small and there are ways to support different versions with ease and minSdkVersion doesn't even affect forward compatibility. Also, supporting multiple versions does not make the final size of the app any larger. Code that is not called for a specific version gets deleted at build time, so you don't have to fear having the app not lean because of lower SDK support. There is some build time performance penalty, but for a simple app, this is not noticeable. And in case there's a blocker with SDK version being too low, it's easier to raise it than lower it.
Bottom line here I'd say is, that it is easy to set a low minSdkVersion from the beginning. The amount of possible issues you'll encounter when lowering that version are probably not worth it and are also harder to fix than supporting a low SDK version from the beginning. And it all massively depends on the actual code.
Based on the comments by Ricky Mo.
The problem is that the default is the "Project View", which contains a build.gradle file that that defines the Kotlin version and the Android Studio Gradle plugin version.
The build.gradle file that defines the minSDK is found in the app folder (screenshot).
Alternatively you can switch from the "Project View" to Android. From the dropdown menu that open when you click "Project" (screenshot, highlighted).

I cannot click on next in Configure Image Asset in Android Studio

When I open the Configure Image Asset in Android Studio by right clicking on res and selecting new -> Image Asset, and after selecting the path to my image and resizing, I cannot press next because the next button is greyed out.
I've tried using the default image as well but the same problem prevails. Much appreciated if someone could shed some light.
Please see the screenshot
Your compileSdkVersion version should be above v26 to use adaptive icons.
For below v26 API Level you can use Legacy Icons Only in Icon Type
The very reason for that is written right there in the bottom:
Project must be built with SDK 26 or later to use adaptive icons.
You must be using Android SDK 25 or lower to build your project. Bump it up from API Level 26 or later as mentioned by #Ranjeet by changing your module-level build.gradle file. Should work fine that way.
Personally I use latest Android API level 29. It is strongly recommended that you always compile with the latest SDK. You’ll get all the benefits of new compilation checks on existing code, avoid newly deprecated APIs etc.

Should the Android compile version be same as the target version in Eclipse?

I need to set the target SDK version of an Android project to API 14. But I do not have the same version available to compile the project. I know that the project can be compiled with a different version but I need to know whether it will cause any issue.
I received the error "Android manifest file is missing" even though it exists. When I cleaned and then built the project it was compiled but the application crashed. What am I doing wrong here?
These were my settings.
There should be no issues introduced when compiling with a higher version, it is even encouraged to do so. You can find more on that topic in this Medium article.
I would also like to bring your attention to the following blog, which contains some important information regarding SDK targeting in the near future.
Unfortunately I do not use Eclipse so I fear cannot provide any verified insight on that matter. However the suggestions I have found so far include:
Cleaning the project
Getting rid of characters such as ö,ë, etc.
Deleting the file and recreating it
The manifest issue was probably due to creating a project with the same name over and over again. However clean -> build the project helped me get rid of it.
Yeah. Android compile version can be higher than the target version.
Android compile version and target version do not have to be the same.
compileSdkVersion
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.
targetSdkVersion
The targetSdkVersion has nothing to do with how your app is compiled or what APIs you can utilize. The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify. This is more like a certification or sign off you are giving the Android OS as a hint to how it should handle your app in terms of OS features.
As for the manifest error, you could try (if you are using android studio) clicking File > Invalidate Caches / Restart or force a gradle sync
Thank you for your answers.
I think the manifest issue was due to creating a project with the same name over and over again. However clean -> build the project helped me get rid of it.
Yeah. Android compile version can be higher than the target version. Those two do not have to be the same.

Android studio 3 forcing me to create project with API 26

I'm trying to create a project with min sdk 18 and target 21. When I initially create a project a select the minimum SDK as 18 however it gives me no option to target 21 and gives me 26 by default. It's giving me a number of features that aren't supported in 18/26 such as android:roundIcon in the manifest and some drawables that I'm having trouble removing without getting errors. I've tried setting the min and target sdk in the build.gradle and then rebuilding the project as well as 'Sync project with gradle files'
EDIT: After deleting the 'mitmap' directory it seemed to resolve the problem but I'm wondering if I should even be deleting this?
Some features are removed (deprecated) in newer API levels, and some features are added or replaced. Generally, you can set your minimum SDK to a low API for example to 15 but if you initially created the project with higher minimum, Android studio gets excited and tries to implement the new stuff, later when you change your mind and specify low API it complains "I thought you wanted the new stuff :(" says the studio.
So you will need to do some refactoring in that case to your code like you just did.
Same applies to existing projects that target minimum API of +21.
When you change it to lower minimum API level things will turn red and it will most likely ask you to do a lot of if/else checking to existing code for API level for some features that work on certain API levels.
I hope that helps.

how to use android-support-v7 ActionBar for version 2.2

I want to have actionbar in my Android Project using android.support.v7.appcompat; and use it in android 2.2 API Version 8.
I Installed Android support library from SDK Manager, and also added the android-support-v7-appcompat from /extras/android/Compatibility/v7/
but the current version of this project is 4.2 (the last version of SDK I have already downloaded). When I add this project as a reference to my project I get error (my resurce file (R) has error and couldn't use R.layout.main)
how can I solve my Problem and use support.v7 ActionBar?
if Change it to Android 4.2; I don't have problem
You are forcing us to have to guess what "it" is.
If "it" is your build target (e.g., Project > Properties > Android in Eclipse), please set that to something like 4.2. This does not control what versions of Android your app runs on. Set your android:minSdkVersion to be 8 (for Android 2.2), as that is what controls what versions of Android your app runs on. Lint will tell you when you are using things that are legal for your build target, but newer than your android:minSdkVersion, so you can make sure that you are using those things appropriately.

Categories

Resources