jamfromouterspace / expo-screen-recorder

Programmatically record screen in an Expo/React Native app using ReplayKit (iOS) and HBRecorder (Android)
8 stars 1 forks source link

npx expo run:android fails to run in a clean expo project. #2

Closed e-shami closed 6 days ago

e-shami commented 2 weeks ago

In an new expo project with nothing else installed except this package, and the plugin you mentioned in the readme.md, when I create a prebuild and then use npx expo run:android to launch the prebuild on a pixel 6 pro emulator for android. I tried the same process on a simulator on mac to run on a simulator for iPhone 13 pro, it worked fine. I have attached the snapshot of the error on android below:

image

kishanshettyb commented 1 week ago

Same issue new

e-shami commented 1 week ago

@kishanshettyb I resolved this problem to be able to create a prebuild and run the project without any error on android by creating a file in the root folder name 'withJvmTargets.js' with the following content in it:

const { withProjectBuildGradle, withAppBuildGradle } = require('@expo/config-plugins');

function withJvmTarget(config) { // Apply changes to the root project build.gradle config = withProjectBuildGradle(config, config => { if (config.modResults.contents) { // Ensure global Kotlin JVM target compatibility config.modResults.contents += allprojects { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { jvmTarget = "17" } } } ; } return config; });

// Apply changes to the app build.gradle config = withAppBuildGradle(config, config => { if (config.modResults.contents) { // Ensure Java toolchain is set config.modResults.contents += java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } } ; } return config; });

return config; }

module.exports = withJvmTarget;


next, I added this file into the plugins section of app.json as follow:

image

after this, I was able to create a prebuild, or a dev build using eas, and run the app on local server, but there is still an issue, while using the package, I get an error related to the 'HBRecorder' of the native implementation of the package. Please try these steps on your side and confirm if you get the same 'next-problem' or this works for you completely.

e-shami commented 6 days ago

I have fixed this issue and created a pull request with the changes in a fork I did. Hope this helps for everyone trying to use the screen recording functionality.

kishanshettyb commented 4 days ago

@e-shami Thank you for the pull request! I’ll check it out to see if it resolves the issue.