5-stones / react-native-readium

📚 📖 React Native ebook reader for iOS, Android, & Web via Readium
MIT License
83 stars 25 forks source link

Support for React Native > 0.71 #47

Closed casperolesen closed 1 month ago

casperolesen commented 6 months ago

I'm trying to use this library with the latest React Native version 0.73.4

But I'm having problems on Android. I'm running the app from an emulator.

How to reproduce

npx react-native@latest init Readium073 yarn add react-native-readium yarn android

or use my repo

https://github.com/casperolesen/Readium073

Java version error

`Execution failed for task ':react-native-readium:compileDebugKotlin'.

'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain`

I've tried to remove this from the build.gradle

kotlinOptions {
    jvmTarget = "1.8"
  }

This fixes the issues with the Java version.

Build failed with an exception

I'm now getting multiple errors when trying to build like

/react-native-readium/android/src/main/java/com/reactnativereadium/ReadiumView.kt:62:7 'when' expression must be exhaustive, add necessary 'is Failure', 'OpenDrmManagementRequested', 'OpenOutlineRequested', 'StartNewSearch' branches or 'else' branch instead /react-native-readium/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt:226:73 Unresolved reference: webView /react-native-readium/android/src/main/java/com/reactnativereadium/reader/EpubReaderFragment.kt:112:55 Unresolved reference: epub_navigator_tag

I can get the build to complete by fixing or removing the lines with errors.

Metro error

Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release

This is were I'm stuck now.

When I remove react-native-readium the app is running fine again.

I'm not an experienced kotlin developer, but I would like to help fixing this! 🦸‍♂️ I just don't know if it's a small bug or something that needs a bigger rewrite of this library.

If someone else can confirm that it's not working with the latest release of React Native - how should we fix it?

jspizziri commented 6 months ago

@casperolesen , I'll look into this when I'm able. However, if you want to start looking into it, my recommendation would be to start by cloning this repo and upgrading the example project to react-native@0.73.4. See if your issues persist once you do that. If they do, send me a PR for the upgrade, and I'll pull it down and see if I can reproduce your issue.

Then we can go from there.

casperolesen commented 6 months ago

Thanks! I'll take a look 👁️

themehdihn commented 6 months ago

So what is the suggested solution to solve this problem? I did not understand anything exactly

jspizziri commented 6 months ago

@themehdihn I (or someone else) needs to look into this as there's some upgrades to the library required. I haven't yet had the time, but feel free to dig around yourself!

themehdihn commented 6 months ago

I (or someone else) needs to look into this as there's some upgrades to the library required. I haven't yet had the time, but feel free to dig around yourself!

Please do this as soon as possible, because no other library is working properly for react-native until now.

jspizziri commented 6 months ago

Please do this as soon as possible

@themehdihn you realize that this is an open source project right?...

Have you paid me or any of the other contributors for their work on this? Why should anyone drop all the other important things they're doing just so you can have what you want?

If you're willing to pay for my time, I'd be happy to drop what I'm doing to investigate this for you.

candidogustavo commented 5 months ago

I could reproduce @jspizziri as you said, i will pass what was necessary change to reproduce the same error.

example/package.json

"react-native": "0.73.6",
"react-native-screens": "^3.30.1",

example/android/build.gradle

buildscript {
    ext {
        ...
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = '25.1.8937393'
        ...
    }
    ...
    dependencies {
        ...
        classpath('com.android.tools.build:gradle')
        ....
    }
    ...
}

example/android/settings.gradle

includeBuild('../node_modules/@react-native/gradle-plugin')

example/andorid/gradle/wrapper/graddle-wrapepr.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
jspizziri commented 4 months ago

@candidogustavo please submit a PR so I can look at a formal diff.

candidogustavo commented 4 months ago

@candidogustavo please submit a PR so I can look at a formal diff.

I am trying to fix it by myself the last two weekends, but i am stuck in an error i have no idea what is the cause, i don´t receive any other kind of error "Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release". Do you have any tip to discover what is happening?

jspizziri commented 4 months ago

@candidogustavo can you share a full stack trace of your error? I have this on my list of things to look into, but I just haven't had the time to get to it yet.

Riandan commented 3 months ago

Hey, I'm running into this issue upgrading my app too. I see some statuses have changed in the last week, just wondering if any work is happening on this or if any work is planned? 👍

jspizziri commented 3 months ago

@Riandan I haven't begun work on it, but its definitely something that will happen eventually. I just need to find the time to do it. Would love to see the community setup in and help make it a reality!

jspizziri commented 1 month ago

This issue is closed by https://github.com/5-stones/react-native-readium/pull/60