I'm upgrading the version of React Native OneSignal to 4.8.0, and in the ChangeLog it says change your Android targetSdk to 33. I currently have compileSdkVersion and targetSdkVersion both set to 31.
What I Want To Know:
Should I also set compileSdkVersion to 33?
If I'm updating one of both of these properties, is there anything else in my code that I should update?
Related
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.
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.
minSdkVersion = 25
compileSdkVersion = 29
targetSdkVersion = 30
It is a React Native project, and the app works well till android 10. issue persist only in android 11.
i tried updating Google WebView which was suggested in a similar issue, but it didnt work..
if anyone have a solution, please share..
Add this line to your app/build.gradle:
implementation("com.squareup.okhttp3:okhttp:4.9.2")
Edit: Although it is resolved since react native #0.67.2
Try to upgrade the compileSdkVersion = 30.
The compileSdkVersion should not be lower than the targetSdkVersion.
this is my build.gradle setting and this is my system info
I'm trying to run the react native app on android 11 but it is keep crashing on launch without giving any error I have tries almost every solution including setting in build.gradle
buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "30.0.0"
ndkVersion = "20.1.5948944"
multiDexEnabled = true
setting ** target API to"30" ** in AndroidManifest.xml
the Gradle version I'm using is
Gradle plugin version is 4.1.3
Gradle version is 6.7**
please help me find the solution in this regard thanks
I got an error like this when setting targetSdk version to 30 it's happening because of okhttp version and fixed it by using the latest version
implementation("com.squareup.okhttp3:okhttp:4.9.1")
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1")
add this in your android/app/build.gradle
This answer has been provided by manohar-octifi (github discussion):
If you are using #sentry/react-native and the version is lower than 2.0.0, then update the version to 2.0.0 or higher (I updated to 2.2.0). This should fix the problem.
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"