software-mansion / react-native-screens

Native navigation primitives for your React Native app.
MIT License
2.91k stars 500 forks source link

Task :react-native-screens:compileReleaseKotlin FAILED #1716

Closed Gabotron-ES closed 1 year ago

Gabotron-ES commented 1 year ago

Description

When doing a gradlew clean assembleRelease to get .aab file of my react-native appI get the following:

> Task :react-native-screens:compileReleaseKotlin FAILED
e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression in (15,47) in C:/xampp/htdocs/WOO!/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt

Attachments:
causeThrowable
java.io.FileNotFoundException: C:\xampp\htdocs\WOO!\node_modules\react-native-screens\android\build\intermediates\compile_r_class_jar\release\R.jar!/node_modules/react-native-screens/android/build/intermediates/compile_r_class_jar/release/R.jar!/com/swmansion/rnscreens/R.class

And:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-screens:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction

It seems .jar file seems missing, this started happening after I changed my app package name (I think...)

I tried upgrading kotlin version to 1.8.0 inside build.gradle but still getting the same error.

kotlinVersion = "1.8.0" //added this inside ext
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0" //added this inside dependencies

My package.json file

"react-native": "0.68.5",
"react-native-screens": "^3.19.0"

I have been stuck with this for a while, I can't uninstall react-native-screens library since react-narive-navigation has a dependency on it (it seems)

Steps to reproduce

  1. Changed package name of my app from com.appname tp com.enterprisename.packagename
  2. did a gradlew clean assembleRelease to get .aab file
  3. App fails to build when it gets to react-native-screens (error seems to be related to kotlin)

Snack or a link to a repository

https://stackoverflow.com/questions/75404806/react-native-cant-get-release-bundle-because-react-native-screens-kotlin-error

Screens version

3.19.0

React Native version

0.68.5

Platforms

Android

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Real device

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 1 year ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

kkafar commented 1 year ago

Hi, @Gabotron-ES, would you mind checking out

kotlinVersion = "1.6.21"

(same version for Kotlin Gradle Plugin)

This is the version we use inside the library and test with.

Moreover you should definitely try out standard approach - reinstall the dependencies: rm -fr node_modules yarn.lock && yarn install and then try to build.

I've tried to build react-native-screens with react-native@0.68.5 and it seems to be working fine. This indicates that this is likely some misconfiguration on your side.

To be able to help you in more concrete wat I would need a repository with a reproduction.

Gabotron-ES commented 1 year ago

Tried it but getting the same error:

e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at (15,47) in C:/xampp/htdocs/WOOO!/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt

Attachments:
expression.kt
R.id.search_src_text
        at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.logOrThrowException(ExpressionTypingVisitorDispatcher.java:253)
        at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:224)

It happens after I change package name of app, followed this tutorial:

https://classnstudy.com/how-to-rename-app-and-change-package-name-in-react-native-for-android/

kkafar commented 1 year ago

@Gabotron-ES, do you think it is possible for you to provide a reproduction of this issue? It is rather hard to guess what is unusual about your setup, especially that I have not encountered this issue earlier.

hanno-jonlay commented 1 year ago

I had a similar screens:compileReleaseKotlin failure with:

Bumping to Kotlin to 1.6.21 resolved this for me.

wdospinal commented 1 year ago

I had a similar screens:compileReleaseKotlin failure with:

react-native-screens@3.22.0 react-native@0.71.7 ext.kotlinVersion = '1.8.21' Bumping to Kotlin to 1.8.21 resolved this for me.I had a similar screens:compileReleaseKotlin failure with:

Rananjaya commented 1 year ago

I have same issue when make ./gradlew bundleRelease, my react-native-screens@3.22.0 and I changed ext.kotlinVersion = '1.8.21', still same issues. any fixed for this ??

Abdelazeem777 commented 11 months ago

Any Solutions?

Sameer-Ijaz commented 9 months ago

I had same issue when compiling android, I solved it by this method https://www.youtube.com/watch?v=7Fhp_1ZxQeg&ab_channel=SgtSam

ahmed-raza12 commented 3 months ago

if it happened after name change, go to mainactivity,kt mainapplication.kt files and at top change your old package name with new one. it should resolve the problem. also update react-native rename global pkg so you dont face this problem again

sampriti026 commented 1 month ago

Hey I solved this issue by upgrading the react-native-screens, i think it was the conflict in the kotlin version mentioned in the build.gradle under node moduls -> react-native-screens-> android and the one i was using in the build.gradle of the root project. (that is android -> build.gradle).

RobertSavage commented 1 month ago

After days and days of trying everything. I just decided to do this and it fixed the problem.

Steps to fix: I deleted my android folder. Created a new temp react native project copied the new android folder over

( Thank you @ahmed-raza12 for this next part ) Ran these commands to rename everything: sudo npm install -g react-native-rename react-native-rename "{project name}"
react-native-rename "{project name}" -b com.{project name}.{project name}

jerome-Dh commented 3 weeks ago

Hey! 👋

This is the version we use inside the library and test with.

Moreover you should definitely try out standard approach - reinstall the dependencies: rm -fr node_modules yarn.lock && yarn install and then try to build.

Thank you Doing this worked for me

rm -fr node_modules package-lock.json && npm install