React Native Task :react-native-image-picker:compileDebugJavaWithJavac FAILED
Asked Answered
C

6

8

When trying to run my project on my windows computer it is not working, it works on my macOS but when running it on windows it throws the following errors:

Task :react-native-image-picker:compileDebugJavaWithJavac FAILED
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
                                                           ^
  symbol:   variable TIRAMISU
  location: class VERSION_CODES

Running it with npx react-native run-android

build.gradle has the following:


buildscript {
    ext {
        buildToolsVersion = "30.0.3"
        minSdkVersion = 30
        compileSdkVersion = 30
        targetSdkVersion = 30
                ndkVersion = "20.1.5948944"
    }

Have been trying to change the number with everything I have installed, 29,30,31,and 33 minSdk, buildTools, compile, and targeted nothing is working.

Currently, have node 14 and JDK 11

Error changes when I use 33 to the following one:

 Task :react-native-webview:compileDebugJavaWithJavac FAILED

Have already tried multiple times ./gradlew clean

Someone knows what's going on? what am I missing?

Cagle answered 9/11, 2022 at 8:46 Comment(5)
What is your RN Version you are currently using?Landwehr
Refer to this GitHub Issue here, there was a global android build issue in react native when they released 0.70.0-rc0. Read github.com/facebook/react-native/issues/35210 to know what action you have to take regarding it.Landwehr
^0.64.1 That's the react native version im currently usingCagle
Consider Upgrading to RN 0.64.4 and test if that solves your issue.Landwehr
tried upgrading to several new ones, different packages differnt errorsCagle
F
7

I downgrade version of react-native-image-picker to 0.38.1, works for me

Farrah answered 21/12, 2022 at 7:33 Comment(2)
Maybe you talked about react-native-image-crop-pickerIow
i'm getting this error npm ERR! notarget No matching version found for [email protected]Roseanneroseate
W
4

Just change the version of your image picker to

"react-native-image-picker": "^4.10.0", 

in Package.Json and then

Delete Node Modules and then Run npm i --force after that cd android and then ./gradlew clean

Works well for me !

Wizen answered 13/10, 2023 at 6:52 Comment(0)
R
1

Downgrade might work but you can also try to upgrade to the latest version. In my case, apparently, npm installed version 4.10.3 when the latest version is 5.3.1. just write:

npm install react-native-image-picker@latest
Remissible answered 24/4, 2023 at 15:9 Comment(0)
B
0
  1. Check if both mac & windows have same java version by running command java -version

  2. If no, change the version of java in windows like as in mac then, clean and rebuild

  3. If yes, check if one of this this solution works :

Brittneybrittni answered 9/11, 2022 at 9:10 Comment(1)
tried everything here and nothing worked :(Cagle
C
0

If your build.gradle has the following:

buildscript {
    ext {
        buildToolsVersion = "30.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30  // or 31
        targetSdkVersion = 30   // or 31
        ndkVersion = "20.1.5948944"
    }

modify inside package.json update image picker version as below,

 "react-native-image-picker": "4.6.0",

or else

If your build.gradle has the following:

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 24
        compileSdkVersion = 33  
        targetSdkVersion = 33  
        // ndkVersion = "21.4.7075529"
        kotlin_version = '1.6.10'
    }

modify inside package.json update image picker version as below,

 "react-native-image-picker": "4.10.0",

Finally, delete node_modules & run npm install --force

Crozier answered 29/7 at 6:40 Comment(0)
K
-2

In my app, the error was fixed by fixing the version of the library in this way: 'react-native-image-picker': '4.6.0', removing the ^ from 'react-native-image-picker': '^4.6.0'. After that, run yarn install or npm install

Kiyohara answered 20/2, 2023 at 16:28 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Wolf

© 2022 - 2024 — McMap. All rights reserved.