I created an app with the API 22 and I want to know if is necessary create a new project to make it compatible with the previous versions (for example with the API 19) or if I can do something simpler and efficient
If you're using gradle just set the minSdkVersion to the number you'd like to use:
defaultConfig {
applicationId "com.example.mypackage"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
in the app's build.gradle file
There are 2 way,
1) Set your "minSdkVersion" from gradle file
or
2) In Android Studio,
File --> Project Structure --> app (on left menu) --> Flavors
then set "Min Sdk Version"
Related
I followed each and every step given on
https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html
I am not able to create Font resource file at the following step -
Right-click the font folder and go to New > Font resource file. The New Resource File window appears.
I am doubtful now, whether I can assign fonts in XML in Android Studio 2.3.3
my build.gradle is as follows
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.crescomobilitysolution.navigationdrawerexercise"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
No, it s supported in Android Studio 3.0 and over
everyone!
I'm new to android programming, so simple things sometimes become a problem.
I have my application. It should work on devices with Android 5 and higher.
The question is what is proper strategy of sdkVersion defining?
What I mean.
For example, I need to acheive permision to use bluetooth.
If my target sdkVersion is 7 and minimum sdkVersion is 5 I should ask permission in manifest file and then acheive it in runtime. Like this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
...
}
But if my target sdkVersion is 5 even Build.VERSION_CODES.M cannot be resolved.
So the question is : what is proper approach to choose sdkVersion? Where can I read about it?
I read here https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#target
but I didn't get what is best practice. So please share your experience.
Read this article from Ian Lake: Picking your compileSdkVersion, minSdkVersion, and targetSdkVersion
compileSdkVersion:
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:
If compileSdkVersion sets the newest APIs available to you,
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:
The most interesting of the three, however, is targetSdkVersion.
targetSdkVersion is the main way Android provides forward
compatibility by not applying behavior changes unless the
targetSdkVersion is updated. This allows you to use new APIs (as you
did update your compileSdkVersion right?) prior to working through the
behavior changes.
Ideally, the relationship would look more like this in the steady state:
minSdkVersion (lowest possible) <=
targetSdkVersion == compileSdkVersion (latest SDK)
I suppose you are using Android Studio and build.gradle. If not, I recommend you to get it. All of the following is relevant for Android Studio and gradle build system.
Your main mistake is that SDK version in build.gradle of app module is not the same as Android Version. Here is the list of Platform Codenames, Versions, API Levels. What you need for SDK version is number in API level column of first table.
This is how android section of build.gradle for app targeting Android 5.0 and newer should look like.
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "net.eraga.myobjectives"
minSdkVersion 21
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'
}
}
}
Read more about targetSdkVersion, minSdkVersion and compileSdkVersion here.
In this case, your minSdkVersion should be 21 (android 5.0) and targetSdkVersion along with compileSdkVersionshould be 25 (android 7.1).
I am trying to deploy a version 1.1 update to my android apk of my worklight app. However when I try to update the versionName on my Manifest and build the project, it automatically gets updated back to 1.0 (updated to 1.1) and versionCode is also auto incremented. I do not want this to happen and I want an updated version 1.1 to be built. Any help here please ?
example entry below... the versionCode got updated to 13 from 12.
android:versionCode="13" android:versionName="1.0"
I use eclipse/worklight and not Android Studio. This auto update is still kind of confusing me.
If you are using Android Studio settings in your app build.gradle will override your app manifest.
Make your changes in build.gradle file
defaultConfig {
applicationId "com.abc.yourapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.1"
}
Try this code to change version
here is link
if it is not working for you then clean project and then rebuild it
meet face to face with trouble that :
java.lang.UnsupportedOperationException: Robolectric does not support API level 1, sorry!
properties in my build gradle :
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
What it can be?
versionCode in your code example is 1, the exception says API level 1 is not supported...I have the impression that "versionCode" represents the API level. What happens if you increase the versionCode - Value?
am not sure about your environment or tool setup, just make sure that your jenkins build is configued to build using gradle/gradle based build tool (only they will parse build.gradle file and generate a Manifest with proper fields) or if u r using some other build tool update the AndroidManifest with appropriate api level values
I need to see which SDKs I can choose, but when I go to the module settings (Android Studio (Preview) 0.5.8) I see only this
and I can't find this settings, where I can choose the Target SDK
How can I do it?
You have to modify the targetSdkVersion field of the build.gradle file.
This is an example:
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0.0"
}
Hope it helped, Mattia