Reputation: 543
I tried building my ionic app after development; but in the process the following errors surfaced:
C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:123: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { ^ > Task :app:compileDebugJavaWithJavac symbol: variable R location: class VERSION_CODES C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:124: error: cannot find symbol dialog.getWindow().getInsetsController().hide(WindowInsets.Type.statusBars()); ^ symbol: variable Type location: class WindowInsets C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:124: error: cannot find symbol dialog.getWindow().getInsetsController().hide(WindowInsets.Type.statusBars()); ^ symbol: method getInsetsController() location: class Window Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
FAILURE: Build failed with an exception.
Task :app:compileDebugJavaWithJavac FAILED 24 actionable tasks: 1 executed, 23 up-to-date
- What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2m 5s c:\incidentApp\platforms\android\gradlew: Command failed with exit code 1 Error output: C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:123: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { ^ symbol: variable R location: class VERSION_CODES C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:124: error: cannot find symbol dialog.getWindow().getInsetsController().hide(WindowInsets.Type.statusBars()); ^ symbol: variable Type location: class WindowInsets C:\incidentApp\platforms\android\app\src\main\java\com\moust\cordova\videoplayer\VideoPlayer.java:124: error: cannot find symbol dialog.getWindow().getInsetsController().hide(WindowInsets.Type.statusBars()); ^ symbol: method getInsetsController() location: class Window Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
I'd tried everything(removing of android package and re-installing) I could lay my hands on but still not working.
Below is my build.gradle
project.ext {
defaultBuildToolsVersion="29.0.3" //String
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}
Upvotes: 30
Views: 64025
Reputation: 1
If someone is still facing "if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)" Even after changing the SDK version and trying the above solutions, your placement/syntax of code might be wrong.
Check if your code is inside the MainActivity Class. placing inside the MainActivity Class worked for me.
Upvotes: 0
Reputation: 116
Just update your sdk version to 33. Because some plugin you added uses android 13 (api 33) check, but couldn't find in your code.
buildscript {
ext {
buildToolsVersion = "30.0.3"
minSdkVersion = 23
compileSdkVersion = 33 // Just increase your sdk version
}
}
Upvotes: 0
Reputation: 1145
I’m using npm i react-native-background-actions then I got this error
and my react native version is "react-native": "0.62.2",
so is just to update the(android/build.gradle) compileSdkVersion 30 to 31
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 31
buildToolsVersion "28.0.3"
}
}
}
}
Upvotes: 0
Reputation: 287
work for me
in android/build.gradle
compileSdkVersion = 32 // <---- increase one by one
Upvotes: 0
Reputation: 111
If you like me, use notifee, look at this:
https://notifee.app/react-native/docs/release-notes
6.0.0 [Android] BREAKING CHANGE: Added support for requesting permission on Android 13 via requestPermission, the minimum compileSdkVersion required has increased to 33. And, to support this feature, the targetSdkVersion must also be increased to 33.
Upvotes: 3
Reputation: 2417
Build.VERSION_CODES.R
only exists in API 30, but you're compiling with API 29.
The compileSdkVersion should be set to 30 if you want to use Build.VERSION_CODES.R
.
As of cordova-android@10, compileSdkVersion
has been removed android-targetSdkVersion
is unified to set both the target & compile SDK versions, so that they always remain consistent.
As of cordova-android@11, the ability to independently set the compile SDK and target SDK separately has returned.
Just like before, use android-targetSdkVersion
preference to set the Target SDK. Use android-compileSdkVersion
preference to set the Compile SDK.
Like before, the target SDK will default to a particular version that cordova-android has been tested with. Cordova-android@11 uses API 32 by default. The compile SDK will default to the configured Target SDK.
Generally speaking, the target and compile should match, but with cordova-android@11 (and 9), you can set the compile SDK higher while keeping the target SDK lower, which can be useful for things that requires the API codes for compatibility checks.
Upvotes: 25
Reputation: 151
buildscript {
ext {
buildToolsVersion = "30.0.3"
minSdkVersion = 21
compileSdkVersion = 33 // increase one by one
}
}
In our case, it was 31 when the error was occurring, we increase it to compileSdkVersion 33, and the error is solved. You can increase it by 1 each time until your error is not solved.
Upvotes: 8
Reputation: 1213
I just changed from compileSdkVersion 30 to compileSdkVersion 31 in build.gradel and everything became okay
Upvotes: 3
Reputation: 399
Check which SDK version you downloaded and make all same that:- compileSdkVersion XX minSdkVersion XX targetSdkVersion XX
Upvotes: -1
Reputation: 2877
Updated-: make sure you set compileSdkVersion
in your android/app/build.gradle file to 31
Old-: I encounter this error while using the Geolocator plugin in the flutter app. to Solve this error you have to open LocationMapper.java (you can find this path in your Debug console). and remove this part
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
and also make sure your android compile version is 30 (For GeoLocator Build.gradle)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
position.put("is_mocked", location.isMock());
}
Upvotes: 28
Reputation: 521
Simply upgrade the compileSdkVersion and targetSdkVersion to 31 in your android/app/build.gradle file.
Upvotes: 39