I created my application before the android pie has been released, in every layout I put android: background = \"white\"
it works fine in every device, but when
You can put this, at the first line in the onCreate
method of your launcher activity.
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
Actually, this answer is especially for React Native developers/apps:
Just like all of us know, the dark mode is fully available on Android 10
Dark theme is available in Android 10 (API level 29) and higher
And most likely this feature ruined your app design implementation, like SVG, font, and background colors. if you decided to fully disable force dark mode
you should follow this approach:
Append the following code inside your <style>
tag in the styles.xml
file:
<item name="android:forceDarkAllowed">false</item>
Note: file path: android/app/src/main/res/values/styles.xml
After step 1 you shoule have something like below:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:forceDarkAllowed">false</item>
</style>
</resources>
Maybe the above stpes don't help you but don't worry, just like is said in the top of this post, this feature is released on API level 29, this means you should change the compiledSdkVersion
to 29 or higher.
To Change the compiledSdkVersion
you should edit the the compiledSdkVersion
in the app gradle properites existed in the android/app/build.gradle
file:
android {
compileSdkVersion 29
Maybe you face compileSdkVersion rootProject.ext.compileSdkVersion
, don't worry you should change this in the android gradle properites existed in the android/build.gradle
file:
buildscript {
ext {
buildToolsVersion = "SomeVersion"
minSdkVersion = SomeVersion
compileSdkVersion = 29 // <======= this should be 29 or higher
targetSdkVersion = SomeVersion
Hint: For being sure that you have a new build, completely delete your last build by using the rm -rf android/app/build
command and uninstall the app on your Emulator/Device and then run yarn android
again.