souvik-ghosh / react-native-create-thumbnail

iOS/Android thumbnail generator with support for both local and remote videos
MIT License
246 stars 105 forks source link

Not working on Android , RN Version 0.65.1 #71

Closed AlbinCederblad closed 1 year ago

AlbinCederblad commented 2 years ago

Describe the bug Fresh install, only importing the module, this is what happens when running app:

BUILD FAILED in 12s

CreateThumbnailModule.java:194: error: exception java.io.IOException is never thrown in body of corresponding try statement
        } catch(IOException e) {

CreateThumbnailModule.java uses or overrides a deprecated API.

* What went wrong:
Execution failed for task ':react-native-create-thumbnail:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

To Reproduce Steps to reproduce the behavior: on android:

  1. npm i react-native-create-thumbnail
  2. start
  3. run-android

Version latest

Haven't added any code yet, so this is simply with a fresh install and importing the module.

souvik-ghosh commented 2 years ago

This got broken when the support for android 13 was added in v1.6.0. This library now requires android API level 10 or above. It's related to the change in the MediaMetadataRetriever.release() API (more info [here](https://developer.android.com/reference/android/media/MediaMetadataRetriever#release())).

@AlbinCederblad, The easiest solution for you would be to use v1.5.1 of this library. And to use the latest version, you can upgrade your project to react-native 69 or later, which will also upgrade the Gradle and android-build-tool versions.

I will add this to the release notes or probably publish release v2.0.0 as it's a breaking change.

AlbinCederblad commented 2 years ago

This got broken when the support for android 13 was added in v1.6.0. This library now requires android API level 10 or above. It's related to the change in the MediaMetadataRetriever.release() API (more info [here](https://developer.android.com/reference/android/media/MediaMetadataRetriever#release())).

@AlbinCederblad, The easiest solution for you would be to use v1.5.1 of this library. And to use the latest version, you can upgrade your project to react-native 69 or later, which will also upgrade the Gradle and android-build-tool versions.

I will add this to the release notes or probably publish release v2.0.0 as it's a breaking change.

Thanks!

cuteWarmFrog commented 2 years ago

This got broken when the support for android 13 was added in v1.6.0. This library now requires android API level 10 or above. It's related to the change in the MediaMetadataRetriever.release() API (more info [here](https://developer.android.com/reference/android/media/MediaMetadataRetriever#release())).

@AlbinCederblad, The easiest solution for you would be to use v1.5.1 of this library. And to use the latest version, you can upgrade your project to react-native 69 or later, which will also upgrade the Gradle and android-build-tool versions.

I will add this to the release notes or probably publish release v2.0.0 as it's a breaking change.

I upgraded rn to 70 and still getting this error.

souvik-ghosh commented 2 years ago

@cuteWarmFrog, Can you please make sure you followed the upgrade guide? Updating just the react-native library won't work.

cuteWarmFrog commented 2 years ago

I upgraded using this tool. It actually works with 1.51 version

souvik-ghosh commented 2 years ago

I upgraded using this tool. It actually works with 1.51 version

@cuteWarmFrog, Sorry, you will also need to add these to the project's build.gradle

compileSdkVersion = 33
targetSdkVersion = 33
cuteWarmFrog commented 2 years ago

@souvik-ghosh I am not sure, that I am able to up these two by 2 versions but still thank you! (tried on empty project, works)

siddharth-kt commented 1 year ago

@souvik-ghosh thanks for the solution but is there any other solution to this since setting compileSdkVersion = 33 targetSdkVersion = 33 might lead to issue with other installed libraries I am also using react-native 0.70.

DanielAraldi commented 1 year ago

In React Native 0.63.4 this is also happening and we are using the most current version.

luisdesouza10 commented 1 year ago

In React Native 0.63.4 this is also happening and we are using the most current version.

+1

DanielAraldi commented 1 year ago

Any news?

souvik-ghosh commented 1 year ago

This is fixed in v1.6.2. The library continues to work on Android < 13. Those who are on android 13, may use 2.0.0-rc.2 (pre-release) for now.

DanielAraldi commented 1 year ago

In my project RN 0.63.4 is still happening. Below is my code in android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "31.0.3"
        minSdkVersion = 16
        compileSdkVersion = 31
        targetSdkVersion = 31
        googlePlayServicesVersion = "17.0.0"
        googlePlayServicesVisionVersion = "19.0.0"
        ndkVersion = "major.minor.build"
    }

Note: I updated the library version to 1.6.2 and 2.0.0-rc.2, it still didn't work. In both versions, in the terminal it showed me this:

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/my_user/Documents/Projects/project/project_app/node_modules/react-native-create-thumbnail/android/build.gradle' line: 45

* What went wrong:
A problem occurred evaluating project ':react-native-create-thumbnail'.
> Could not find method namespace() for arguments [com.reactlibrary.createthumbnail] on extension 'android' of type com.android.build.gradle.LibraryExtension.

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

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-create-thumbnail'.
> compileSdkVersion is not specified. Please add it to build.gradle
souvik-ghosh commented 1 year ago

In my project RN 0.63.4 is still happening. Below is my code in android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "31.0.3"
        minSdkVersion = 16
        compileSdkVersion = 31
        targetSdkVersion = 31
        googlePlayServicesVersion = "17.0.0"
        googlePlayServicesVisionVersion = "19.0.0"
        ndkVersion = "major.minor.build"
    }

Note: I updated the library version to 1.6.2 and 2.0.0-rc.2, it still didn't work. In both versions, in the terminal it showed me this:

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/my_user/Documents/Projects/project/project_app/node_modules/react-native-create-thumbnail/android/build.gradle' line: 45

* What went wrong:
A problem occurred evaluating project ':react-native-create-thumbnail'.
> Could not find method namespace() for arguments [com.reactlibrary.createthumbnail] on extension 'android' of type com.android.build.gradle.LibraryExtension.

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

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-create-thumbnail'.
> compileSdkVersion is not specified. Please add it to build.gradle

@DanielAraldi Sorry to hear this. Could you please try v1.6.3 and confirm if it works? looks like the namespace method is not supported in older Gradle versions.

DanielAraldi commented 1 year ago

VERSION 1.6.3 WORKED! Finally a stable version haha! Thank you very much!

luisdesouza10 commented 1 year ago

Version 1.6.3 still accusing:

> Task :react-native-create-thumbnail:androidJavadoc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-create-thumbnail:androidJavadoc'.

> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/x/node_modules/react-native-create-thumbnail/android/build/tmp/androidJavadoc/javadoc.options'
Bimbimz commented 1 year ago

i have this problem. iam use "react-native": "0.70.1" i try 1.6.3 2.0.0-rc.2 and compileSdkVersion = 33 targetSdkVersion = 33 remains the same what is the solution?

AlirezaHadjar commented 1 year ago

I handled to run v1.6.3 on rn0.70 by applying the following patch

diff --git a/node_modules/react-native-create-thumbnail/android/src/main/java/com/createthumbnail/CreateThumbnailModule.java b/node_modules/react-native-create-thumbnail/android/src/main/java/com/createthumbnail/CreateThumbnailModule.java
index 9bd67d8..8f14cce 100644
--- a/node_modules/react-native-create-thumbnail/android/src/main/java/com/createthumbnail/CreateThumbnailModule.java
+++ b/node_modules/react-native-create-thumbnail/android/src/main/java/com/createthumbnail/CreateThumbnailModule.java
@@ -189,7 +189,11 @@ public class CreateThumbnailModule extends ReactContextBaseJavaModule {
         }

         Bitmap image = retriever.getFrameAtTime(time * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
-        retriever.release();
+        try {
+            retriever.release();
+        } catch(IOException e) {
+            e.printStackTrace();
+        }
         if (image == null) {
             throw new IllegalStateException("File doesn't exist or not supported");
         }
Bimbimz commented 1 year ago

i have this problem. iam use "react-native": "0.70.1" i try 1.6.3 2.0.0-rc.2 and compileSdkVersion = 33 targetSdkVersion = 33 remains the same what is the solution?

Edit: Sorry its Work fine whiteout edit or change.

"react-native": "0.70.1" "react-native-create-thumbnail": "^1.6.3"

TheScalion commented 1 year ago

"react-native-create-thumbnail": "^2.0.0-rc.2",

izuutech commented 1 year ago

I am having this same issue. I am on "react-native": "0.71.7" and "react-native-create-thumbnail": "^1.6.4". I have set the compileSdkVersion and targetSdkVersion to 33 respectively and it's still not building