SDK version 29 not modified after migrated the developer preview android-R - android

I'm trying to implement newer android SDK in my app with below configurations,
android {
compileSdkVersion 'android-R'
buildToolsVersion "30.0.0-rc4"
defaultConfig {
minSdkVersion 14
targetSdkVersion 'R'
}
...
}
I need some clarification,
We have faced the SDK version 29 was not modified after migrated the developer preview android-R. I think the SDK version is 30 right?
I have compared both android 29 & android R build.prop files & SDK version is the same as 29. But in android-R build.prop file release or codename parameter is 'R'. Please confirm for us.

Related

Could not find method compileSdk() for arguments [30] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension

I got the above error compileSdk() not found. While creating the app I have installed TargetSdk 31 and min SDK 19 But Apk does not install on Oreo Version so I have changed TargetSdk 31 to 31 and minSdk 19 to 16. I have uninstalled SDK 31 but it partially uninstalls. Please help me to solve this problem I am new to Android.
I have been strugling with this issue for hours until I looked at some older project. For some reason, newer versions of Android Studio mess up the directives from the Gradle file.
Just add "Version" after the name and it will work. So where you see "compileSdk" just rename it to "compileSdkVersion". You will probably also have to do that in "targetSdk" and so on.
in your <android_proj>/app/build.grandle instead of targetSdk 30 use:
android {
...
defaultConfig {
...
targetSdkVersion 30
}
}

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.

React Native Android needs to target API level 29 before November 2, 2020

As per the new Google Play policy, all apps must target at least Android 10 (API 29) before November 2, 2020.
More info: https://developer.android.com/distribute/play-policies
React Native is targeting API 28 as of today(v0.63), are there any plans to update the target SDK version?
Open android/build.gradle in your React Native project and change compileSdkVersion and targetSdkVersion values to 29.
android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.5"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
}
Then go Android Studio and Run "Sync Project with File System" (File > Sync Project with Gradle Files).
It's necessary to upgrade your React Native version. You can see the instructions here.
A simple cli upgrade did the trick for me:
npx react-native upgrade

Adding React-Native-Admob in React-Native

I am trying to add React-Native-Admob 2.0.0-beta.5 into React-Native v0.55.4 for Android.
compileSdkVersion =26
buildToolsVersion ="27.0.3"
targetSdkVersion = 26
supportLibVersion = "26.1.0"
minSdkVersion = 18
And React-Native-Admob has
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
}
And when i Compile the error Exception occur
The SDK Build Tools revision (23.0.1) is too low for project ':react-native-admob'. Minimum required is 25.0.0
I can't downgrade my project's SDK, other package uses that SDK.
You don't need to downgrade, you need to upgrade. Dependencies were probably added in the SDK that admob relies on. You can download the specified version packages for the SDK through Android studio and then set your SDK version in the file to the appropriate version necessary for admob.
Edit
I see that you are saying that admob is using version 23. You may need to submit an issue with them on GitHub for this.
you can change the buildToolVersion of the library you are using, just go to -> node_modules/{your-library}/android/build.gradle, change buildToolsVersion from 23.0.1 to 25.0.0.
if the studio asks for any updates regarding build, just update it, and it might work.
another solution:
although I haven't tried it, it has a lot of emoji love on GitHub,
https://github.com/oblador/react-native-keychain/issues/68#issuecomment-304836725
Goto
"node-module/react-native-admob/android/build.gradle" file, then change the compileSdkVersion and buildToolsVersion to following values
compileSdkVersion 27
buildToolsVersion "27.0.3"

What is the buildToolsVersion for android SDK 24?

There's not much I can say about this. Oh well. Google released a new version of android called Nougat (android N). It is compileSdkVersion 24. However, on the build tools page in the official documentation, it is not mentioned.
I want to give my app to 100% of the people using Google Play Store, which includes android N users.
tl;dr: What should I fill in the buildToolsVersion field?
Thanks.
buildToolsVersion
Using android gradle plugin version > 3 you can remove the android.buildToolsVersion property
Quoting from the New Features section of the Android Gradle plugin release notes for version 3.0.0:
You no longer need to specify a version for the build tools. By default, the plugin automatically uses the minimum required build tools version for the version of Android plugin you're using.
[minSdkVersion, targetSdkVersion, compileSdkVersion]
buildToolsVersion should be set to 25 and 25.0.0, as seen below:
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
You can get the latest buildToolsVersion from SDK Manager in Android Studio.

Categories

Resources