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

[Android] Add support for RN 0.72.6 #6

Open
sorinrinse opened this issue Oct 12, 2023 · 3 comments
Open

[Android] Add support for RN 0.72.6 #6

sorinrinse opened this issue Oct 12, 2023 · 3 comments

Comments

@sorinrinse
Copy link

Currently, building this library on Android fails on new and old projects.

On new projects it crashes with the following error:

* Where:
Build file '<path>/Projects/AwesomeProject/node_modules/react-native-capture/android/build.gradle' line: 111

A problem occurred configuring project ':react-native-capture'.
> Could not resolve all files for configuration ':react-native-capture:implementation'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :react-native-capture
      > Cannot choose between the following variants of com.facebook.react:react-android:0.72.6:
          - debugVariantDefaultRuntimePublication
          - releaseVariantDefaultRuntimePublication
        All of them match the consumer attributes:
          - Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-android:0.72.6:
              - Unmatched attributes:
                  - Provides com.android.build.api.attributes.BuildTypeAttr 'debug' but the consumer didn't ask for it
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'releaseVariantDefaultRuntimePublication' capability com.facebook.react:react-android:0.72.6:
              - Unmatched attributes:
                  - Provides com.android.build.api.attributes.BuildTypeAttr 'release' but the consumer didn't ask for it
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'aar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

On old projects (upgraded from 1.3.0 to 1.4.17), the same task (androidSourcesJar) fails with the following error:

A problem occurred configuring project ':react-native-capture'.
> Could not set unknown property 'classifier' for task ':react-native-capture:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar
@sorinrinse sorinrinse changed the title [Android] Add support for RN 0.72.5 [Android] Add support for RN 0.72.6 Oct 12, 2023
@jefflewis
Copy link

jefflewis commented Oct 13, 2023

I ran into this as well have applied this patch to make it work

diff --git a/node_modules/react-native-capture/android/build.gradle b/node_modules/react-native-capture/android/build.gradle
index a2c5e53..00aaa01 100644
--- a/node_modules/react-native-capture/android/build.gradle
+++ b/node_modules/react-native-capture/android/build.gradle
@@ -30,7 +30,7 @@ buildscript {
     if (project == rootProject) {
         repositories {
             google()
-            jcenter()
+            mavenCentral()
         }
         dependencies {
             classpath 'com.android.tools.build:gradle:4.2.0'
@@ -63,12 +63,16 @@ repositories {
     }
     mavenCentral()
     google()
-    jcenter()
 }
 
 dependencies {
     //noinspection GradleDynamicVersion
-    implementation fileTree(dir: "libs", include: ["*.aar", "*.jar"])
+//    implementation(name: 'capture', ext: 'jar', version: '1.6.15')
+//    implementation(name: 'capture-common', ext: 'jar', version: '1.6.15')
+//    implementation(name: 'capture_socketcam', ext: 'aar')
+    compileOnly files('libs/capture-1.6.15.jar')
+    compileOnly files('libs/capture-common-1.6.15.jar')
+    compileOnly files('libs/capture_socketcam.aar')
     implementation 'com.facebook.react:react-native:+'  // From node_modules
     implementation 'com.google.zxing:core:3.5.1'
 }
@@ -104,21 +108,21 @@ def configureReactNativePom(def pom) {
 afterEvaluate { project ->
     // some Gradle build hooks ref:
     // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
-    task androidJavadoc(type: Javadoc) {
-        configurations.implementation.canBeResolved = true
-        source = android.sourceSets.main.java.srcDirs
-        classpath += files(android.bootClasspath)
-        classpath += files(project.getConfigurations().getByName('implementation').asList())
-        include '**/*.java'
-    }
-
-    task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
-        classifier = 'javadoc'
-        from androidJavadoc.destinationDir
-    }
+//    task androidJavadoc(type: Javadoc) {
+//        configurations.implementation.canBeResolved = true
+//        source = android.sourceSets.main.java.srcDirs
+//        classpath += files(android.bootClasspath)
+//        classpath += files(project.getConfigurations().getByName('implementation').asList())
+//        include '**/*.java'
+//    }
+
+//    task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
+//        classifier = 'javadoc'
+//        from androidJavadoc.destinationDir
+//    }
 
     task androidSourcesJar(type: Jar) {
-        classifier = 'sources'
+        archiveClassifier = 'sources'
         from android.sourceSets.main.java.srcDirs
         include '**/*.java'
     }
@@ -134,7 +138,7 @@ afterEvaluate { project ->
 
     artifacts {
         archives androidSourcesJar
-        archives androidJavadocJar
+//        archives androidJavadocJar
     }
 
     task installArchives(type: Upload) {

Additionally, I'll note that the following is required in your app/build.gradle 's dependencies:

implementation(files("$rootDir/../node_modules/react-native-capture/android/libs/capture-1.6.15.jar"))
implementation(files("$rootDir/../node_modules/react-native-capture/android/libs/capture-common-1.6.15.jar"))
implementation(files("$rootDir/../node_modules/react-native-capture/android/libs/capture_socketcam.aar"))

@socketPM
Copy link

@sorinrinse yes, this is an known issue. We are working on adding the support for RN 0.72.6 and React V18.2 @jefflewis thanks for providing a workaround!

@sdksupport-socketmobile
Copy link
Contributor

sdksupport-socketmobile commented Feb 15, 2024

@sorinrinse Apologies for the late reply. While we were able to upgrade React to 18.2, we are currently working on a migration which should be wrapped up end of next week. The following week we will start work on upgrading the React Native version to >0.72.6. Thank you for your patience!

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

4 participants