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

not working in my project #75

Open
shekhar1911 opened this issue Jan 30, 2025 · 3 comments
Open

not working in my project #75

shekhar1911 opened this issue Jan 30, 2025 · 3 comments

Comments

@shekhar1911
Copy link

with expo its not working why?

@pranavbabu
Copy link

It is working in expo, could you please add more context?

@Jervi-sir
Copy link

It is working in expo, could you please add more context?

really?,
m I missing something, I have encountered is error
(NOBRIDGE) ERROR Error: NitroModules are not supported in Expo Go! Use EAS (expo prebuild) or eject to a bare workflow instead.
like we have to give up Expo managed environment :.(

@pranavbabu
Copy link

here is what I do in order to make it work:
I use patch-package lib to make direct changes to lib, here is how patch looks:

diff --git a/node_modules/react-native-photo-editor/android/build.gradle b/node_modules/react-native-photo-editor/android/build.gradle
index 603a049..e80506a 100644
--- a/node_modules/react-native-photo-editor/android/build.gradle
+++ b/node_modules/react-native-photo-editor/android/build.gradle
@@ -44,7 +44,7 @@ repositories {
 
 dependencies {
     implementation 'com.facebook.react:react-native:+'
-    implementation 'com.github.prscX:photo-editor-android:master'
+    implementation 'com.github.Rauzon:photo-editor-android:v1.1.0'
     implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
     implementation 'com.nineoldandroids:library:2.4.0'
     implementation 'com.android.support:design:28.0.0'

and also I created withPhotoEditor.js plugin for expo, put it in plugins/withPhotoEditor.js folder

const fs = require("fs");
const path = require("path");
const { withAndroidManifest, withDangerousMod } = require("@expo/config-plugins");

// Function to modify the iOS Podfile properly inside the target block
function modifyPodfile(config) {
  return withDangerousMod(config, [
    "ios",
    async (config) => {
      const podfilePath = path.join(config.modRequest.platformProjectRoot, "Podfile");

      if (fs.existsSync(podfilePath)) {
        let podfileContent = fs.readFileSync(podfilePath, "utf-8");

        const newPods = `
  pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios'
  pod 'iOSPhotoEditor', :git => 'https://github.com/prscX/photo-editor', :branch => 'master'
`;

        // Ensure it's inside the target block
        const targetRegex = /target\s+['"]Maindeck['"]\s+do([\s\S]*?)end/;
        const match = podfileContent.match(targetRegex);

        if (match) {
          const targetBlock = match[0];

          if (!targetBlock.includes("pod 'RNPhotoEditor'")) {
            const updatedTargetBlock = targetBlock.replace(/(use_react_native!\([\s\S]*?\))/, `$1\n${newPods}`);
            podfileContent = podfileContent.replace(targetBlock, updatedTargetBlock);
            fs.writeFileSync(podfilePath, podfileContent, "utf-8");
          }
        }
      }

      return config;
    },
  ]);
}

// Function to modify AndroidManifest.xml
function addExtraActivityToApplication(androidManifest) {
  const { manifest } = androidManifest;

  if (!Array.isArray(manifest["application"])) {
    console.warn("withIntentActivity: No application array in manifest?");
    return androidManifest;
  }

  const application = manifest["application"].find(
    (item) => item.$["android:name"] === ".MainApplication"
  );

  if (!application) {
    console.warn("withIntentActivity: No .MainApplication?");
    return androidManifest;
  }

  if (!Array.isArray(application["activity"])) {
    console.warn("withIntentActivity: No activity array in .MainApplication?");
    return androidManifest;
  }

  const photoeditorActivity = {
    $: {
      "android:name": "com.ahmedadeltito.photoeditor.PhotoEditorActivity",
    },
  };

  application["activity"].push(photoeditorActivity);

  return androidManifest;
}

// Main config plugin
module.exports = function withPhotoEditor(config) {
  config = withAndroidManifest(config, (config) => {
    config.modResults = addExtraActivityToApplication(config.modResults);
    return config;
  });

  config = modifyPodfile(config);

  return config;
};

then reference it in app.json config like so:

    "plugins": [
      [
        "./plugins/withPhotoEditor.js"
      ],

then run expo prebuild to get fresh ios or android folders, but Expo Go is not working, it works with Expo Build and you can ignore ios and android folders when you push code to EAS and it will work.

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

No branches or pull requests

3 participants