Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.6.0 - Task: react-native-screens:ktlint FAILED #1090

Closed
brunorafaeI opened this issue Aug 27, 2021 · 10 comments · Fixed by #1093
Closed

v3.6.0 - Task: react-native-screens:ktlint FAILED #1090

brunorafaeI opened this issue Aug 27, 2021 · 10 comments · Fixed by #1093

Comments

@brunorafaeI
Copy link

brunorafaeI commented Aug 27, 2021

Description

When I'm trying to build my project I have this issue :

...
~/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:19:1: Unexpected indentation (4) (should be 2)
~/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:20:2: Redundant newline (\n) at the end of file

> Task :react-native-screens:ktlint FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-screens:ktlint'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* 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.

Screenshots

Steps To Reproduce

  1. Build Android project with @react-navigation/native

Expected behavior

It builds successfully 🤞

Actual behavior

It throws the above error ⬆️

Additional Information

I'm using WSL2 (Debian 10 buster) to run my project and running the emulator from windows 10 64 bits, it was worked very well before trying to install @react-navigation/native

Package versions

  • React: 17.0.2
  • React Native: 0.65.1
  • React Native Screens: 3.6.0
@brunorafaeI brunorafaeI changed the title v3.6.0 - Task: react-native-screens:ktlint FAILED [Android] v3.6.0 - Task: react-native-screens:ktlint FAILED Aug 27, 2021
@brunorafaeI
Copy link
Author

Hi there!

I've changed the version of java to OpenJDK 8 and executed "./gradlew clean", but I have the same error!
Someone can help me pls?

@kacperkapusciak
Copy link
Member

Hi @brunorafaeI,
It looks like a script or someone by hand changed Android files in the node_modules/react-native-screens/ directory.
Reinstalling react-native-screens should fix your issue.

yarn remove react-native-screens
yarn add react-native-screens

Or remove the whole node_modules directory and reinstall packages with yarn.
If it doesn't help, could you provide a full, complete error message?

Cheers

@brunorafaeI
Copy link
Author

brunorafaeI commented Aug 30, 2021

Hi @brunorafaeI,
It looks like a script or someone by hand changed Android files in the node_modules/react-native-screens/ directory.
Reinstalling react-native-screens should fix your issue.

yarn remove react-native-screens
yarn add react-native-screens

Or remove the whole node_modules directory and reinstall packages with yarn.
If it doesn't help, could you provide a full, complete error message?

Cheers

Hi @kacperkapusciak,

Thanks for your response! I did what you mentioned, but I still have the same error :

t.kt:10:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:11:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:13:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:14:1: Unexpected indentation (8) (should be 4)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:15:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:17:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:18:1: Unexpected indentation (8) (should be 4)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:19:1: Unexpected indentation (4) (should be 2)
/home/brafael/bootcamp/nv03/mobile/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt:20:2: Redundant newline (\n) at the end of file

> Task :react-native-screens:ktlint FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-screens:ktlint'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* 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 1m 44s
291 actionable tasks: 291 executed
error Failed to build the app.
Error: Command failed: ./gradlew build -x lint
    at makeError (/home/brafael/bootcamp/nv03/mobile/node_modules/execa/index.js:174:9)
    at Function.module.exports.sync (/home/brafael/bootcamp/nv03/mobile/node_modules/execa/index.js:338:15)
    at buildApk (/home/brafael/bootcamp/nv03/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:181:22)
    at runOnSpecificDevice (/home/brafael/bootcamp/nv03/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:162:7)
    at buildAndRun (/home/brafael/bootcamp/nv03/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:147:12)
    at /home/brafael/bootcamp/nv03/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:132:12
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Command.handleAction (/home/brafael/bootcamp/nv03/mobile/node_modules/@react-native-community/cli/build/index.js:186:9)

@brunorafaeI
Copy link
Author

brunorafaeI commented Aug 31, 2021

Any help?

just for info without react-native-screens, my project finishes well the build.

info Fetching system and libraries information...
System:
    OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 2.43 GB / 12.40 GB
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.4/bin/yarn
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.12 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.65.1 => 0.65.1 
  npmGlobalPackages:
    *react-native*: Not Found

@kacperkapusciak
Copy link
Member

@brunorafaeI could you check if applying changes from #1093 fixes your issue?

E.g. you can install package directly from branch with yarn add git+https://github.com/software-mansion/react-native-screens#@kacperkapusciak/add-spotless or change files by hand

@brunorafaeI
Copy link
Author

brunorafaeI commented Sep 1, 2021

@kacperkapusciak thanks so much!! Its works now very well.

Can I know what was the problem? and I'll stay with this version of react-native-screens instead of the official version ??

@kacperkapusciak
Copy link
Member

@brunorafaeI probably next week we'll release next version of screens with this change so till this time you'll have to keep using this fix.

Linters are used to check for code quality and error out when something isn't like it's supposed to be. Previous configuration checked not only when we were developing but also on the user's (yours!) computer when using our library. That wouldn't be a problem by itself but somehow your code in node_modules differs slightly or uses different formatting than we are. In short - we used linter that worked a bit too well :)

If I'd have to guess, your IDE automatically reformats code to your preffered style including node_modules directory. Normally developers shouldn't change anything in node_modules unless they have a specific purpose 🙂

Cheers

@brunorafaeI
Copy link
Author

brunorafaeI commented Sep 1, 2021

@brunorafaeI probably next week we'll release next version of screens with this change so till this time you'll have to keep using this fix.

Linters are used to check for code quality and error out when something isn't like it's supposed to be. Previous configuration checked not only when we were developing but also on the user's (yours!) computer when using our library. That wouldn't be a problem by itself but somehow your code in node_modules differs slightly or uses different formatting than we are. In short - we used linter that worked a bit too well :)

If I'd have to guess, your IDE automatically reformats code to your preffered style including node_modules directory. Normally developers shouldn't change anything in node_modules unless they have a specific purpose 🙂

Cheers

@kacperkapusciak I get it, thanks so much!

kacperkapusciak added a commit that referenced this issue Sep 6, 2021
Using `ktlint` directly as gradle task is very powerful and flexible but due to problems (#1085, #1090) we've decided to use formatting/linting framework - Spotless.
@brunorafaeI
Copy link
Author

brunorafaeI commented Sep 9, 2021

Hey @kacperkapusciak , is this fix not available in the release version yet?

@kacperkapusciak
Copy link
Member

@brunorafaeI version with this fix went live a few hours after your comment 🙂 You can now upgrade Screens to v3.7.0👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants