Shopify / react-native-skia

High-performance React Native Graphics using Skia
https://shopify.github.io/react-native-skia
MIT License
6.81k stars 438 forks source link

Build failing for React-native 0.69.0 #627

Closed abdullahIsa closed 2 years ago

abdullahIsa commented 2 years ago

Hello, i am upgraded my react native and started to get this error, not sure whats the cause, thanks.

PS C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0> npm run android

> appname@0.0.9 android
> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 2265 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

> Configure project :lottie-react-native
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the 
Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :react-native-reanimated
Native libs debug enabled: true
Android gradle plugin: 7.1.1
Gradle: 7.3.3
building Reanimated2
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the 
Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :shopify_react-native-skia
react-native-skia: node_modules/ found at: C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules
react-native-skia: React Native version: 69
react-native-skia: Is Source build: false
react-native-skia: Prebuilt dir: C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\@shopify\react-native-skia\android\build/react-native-0*/jni

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
6 actionable tasks: 6 up-to-date

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\@shopify\react-native-skia\android\build.gradle' line: 178
* What went wrong:
A problem occurred evaluating project ':shopify_react-native-skia'.
> Expected directory 'C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules/react-native/android' to contain exactly one file, however, it contains more than one file.

* 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 22s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\@shopify\react-native-skia\android\build.gradle' line: 178
* What went wrong:
A problem occurred evaluating project ':shopify_react-native-skia'.
> Expected directory 'C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules/react-native/android' to contain exactly one file, however, it contains more than one file.

* 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 22s

    at makeError (C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\execa\index.js:174:9)
    at C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\execa\index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
    at async Command.handleAction (C:\Users\Abdullah\Desktop\Programming\company\apps\AppName\AppName-0.69.0\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
chrfalch commented 2 years ago

Possibly related to #624

quicksilverr commented 2 years ago

Hey @chrfalch This is turning out to be a blocker for building it on android. Any idea, how we can resolve this issue?

hungnq139 commented 2 years ago

@quicksilverr replace def rnAAR = fileTree("${nodeModules}/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile

with def buildType = "debug" tasks.all({ task -> if (task.name == "buildCMakeRelease") { buildType = "release" } }) def rnAarMatcher = "**/react-native/**/*${buildType}.aar" def rnAAR = fileTree("${nodeModules}/react-native/android").matching({ it.include rnAarMatcher }).singleFile

chrfalch commented 2 years ago

Awesome @hungnq139! I had a similar fix - seems to work when synching but still fails in CMake when compiling. Is this your experience as well?

quicksilverr commented 2 years ago

@hungnq139 Please could you share which file we need to do this in?

chrfalch commented 2 years ago

@hungnq139 Please could you share which file we need to do this in?

In the gradle-file found here under your project root: node_modules/@shopify/react-native-skia/android/build.gradle

quicksilverr commented 2 years ago

@chrfalch Yes, I also have a similar experience. It fails in CMake while compiling, I double checked, I do have CMake installed in android studio.

chrfalch commented 2 years ago

Could you try adding the following to the CMakeLists.txt file after line 55:

"${NODE_MODULES_DIR}/react-native/ReactCommon"
quicksilverr commented 2 years ago

Hey @chrfalch I tried adding your suggestion, but this is the error that I'm facing while, running yarn android

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
[CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.
[CXX1301] - CMake '3.18.1' found in SDK did not satisfy requested version.
[CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.
[CXX1301] - CMake '3.18.1' found in SDK did not satisfy requested version.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':shopify_react-native-skia'.
> [CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.

I have installed CMake from android studios -> sdk manager, shall I download the downgraded version?

It works, downloaded the needed version, thanks a lot guys, shall we create a PR for it?

chrfalch commented 2 years ago

Great that it works. The Android build system for building C++ code in React Native is (in my opinion) still a bit immature, like which version of CMake to use etc. We're super happy for PRs and contributions, so go ahead @quicksilverr!

thespacemanatee commented 2 years ago

@chrfalch after upgrading to expo sdk 46, on EAS build we are facing the error as described by @quicksilverr. AFAIK, there is no way to specify CMake version on EAS, any possible fixes we can do on the library side of things?

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
[CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.
[CXX1301] - CMake '3.18.1' found in SDK did not satisfy requested version.
[CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.
[CXX1301] - CMake '3.18.1' found in SDK did not satisfy requested version.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':shopify_react-native-skia'.
> [CXX1300] CMake '3.10.2' was not found in SDK, PATH, or by cmake.dir property.
brentvatne commented 2 years ago

@thespacemanatee - this project will show you how to set up CMake appropriately: https://github.com/brentvatne/try-skia - notice the eas-build-pre-install hook in package.json and pre-install.sh

cc @Kudo / @chrfalch - we should coordinate on making this work out of the box on eas build, this was a bit of an oversight on our part

thespacemanatee commented 2 years ago

@brentvatne Thank you for the repo. Had to make sure to chmod +x the script as well otherwise it would through permission error on EAS build servers.

Kudo commented 2 years ago

@chrfalch is cmake 3.10.2 here is a hard requirement? is it possible to remove the line to make it more flexible?

supposedly AGP could download required cmake automatically. someone came across similar issues as well. not sure whether it's license issue or what.

chrfalch commented 2 years ago

It shouldn't be a hard requirement - I've created an issue to follow up on this one: #739

Kudo commented 2 years ago

thanks @chrfalch for the fix 🎉

chrfalch commented 2 years ago

Np, @Kudo!! Thanks for the suggestion :) :) We will release a new version very soon with this and some other fixes.