AdaptySDK-React-Native icon indicating copy to clipboard operation
AdaptySDK-React-Native copied to clipboard

expo 49 migration

Open rafakwolf opened this issue 1 year ago • 9 comments

Hi folks, I'm migrating from expo 48 to 49 ... and the gradle version is being migrated to version 8. And react-native-adapty is throwing an error:

* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find io.adapty.internal:crossplatform:2.4.2.
     Searched in the following locations:
       - file:/Users/rafael/dev/preco-teto-acoes/node_modules/react-native/android/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
       - file:/Users/rafael/dev/preco-teto-acoes/node_modules/jsc-android/dist/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
       - https://dl.google.com/dl/android/maven2/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
       - https://repo.maven.apache.org/maven2/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
       - https://www.jitpack.io/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
       - https://oss.sonatype.org/content/repositories/snapshots/io/adapty/internal/crossplatform/2.4.2/crossplatform-2.4.2.pom
     Required by:
         project :app > project :react-native-adapty

Can I have some help?

Thank you!

Originally posted by @rafakwolf in https://github.com/adaptyteam/AdaptySDK-React-Native/discussions/79

rafakwolf avatar Jul 10 '23 14:07 rafakwolf

Hey! Having a look...

divanc avatar Jul 11 '23 11:07 divanc

Same issue with a bare react-native project (no expo) using RN 0.72.3

* What went wrong:                                                                                                                                                                                                                                                                                        
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.                                                                                                                                                                                                                            
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.                                                                                                                                                                                                                 
   > Could not find io.adapty.internal:crossplatform:2.4.2.                                                                                                                                                                                                                                               
     Required by:                                                                                                                                                                                                                                                                                         
         project :app > project :react-native-adapty     

There was a suggestion in similar issue to manually include the maven repo via the following. Note path was adjusted for monorepo.

        maven {
            url "$rootDir/../../../node_modules/react-native-adapty/lib/android/localMaven"
        }

This made no difference.

jasonpeinko avatar Jul 15 '23 13:07 jasonpeinko

Was able to get a build working by setting the local repository under allProjects rather than buildScript.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
        maven {
            url "$rootDir/../../../../node_modules/react-native-adapty/lib/android/localMaven" // <---- This didn't work
        }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
    }

    allprojects {
        project.pluginManager.withPlugin("com.facebook.react") {
            react {
                reactNativeDir = rootProject.file("../../../node_modules/react-native/")
                codegenDir = rootProject.file("../../../node_modules/@react-native/codegen/")
            }
        }
    }

}

allprojects {
    repositories {
        maven {
            url "$rootDir/../../../node_modules/react-native-adapty/lib/android/localMaven" // <----- This worked
        }
    }
    project.pluginManager.withPlugin("com.facebook.react") {
        react {
            reactNativeDir = rootProject.file("../../../node_modules/react-native/")
            codegenDir = rootProject.file("../../../node_modules/@react-native/codegen/")
        }
    }
}

jasonpeinko avatar Jul 15 '23 19:07 jasonpeinko

@divanc Hello, anything new about this? Thank you!

rafakwolf avatar Jul 25 '23 18:07 rafakwolf

I was able to solve it via app.json. Add under plugins expo-build-properties:

[
  "expo-build-properties",
  {
    "android": {
      "extraMavenRepos": [
        "../../node_modules/react-native-adapty/lib/android/localMaven"
      ]
    },
  }
],

If you are in a monorepo, then use "$rootDir/../../../node_modules/react-native-adapty/lib/android/localMaven" instead of the other path. :)

megacherry avatar Aug 19 '23 16:08 megacherry

I was able to solve it via app.json. Add under plugins expo-build-properties:

[
  "expo-build-properties",
  {
    "android": {
      "extraMavenRepos": [
        "../../node_modules/react-native-adapty/lib/android/localMaven"
      ]
    },
  }
],

If you are in a monorepo, then use "$rootDir/../../../node_modules/react-native-adapty/lib/android/localMaven" instead of the other path. :)

I encountered the same problem with expo run: android --device , building using eas was fine. Thanks @megacherry for this workaround, it works for me.

I encountered another problem after this. Expo somehow screws up the namespace in the build.gradle file, so the local development build will fail. The problem exists in both SDK48 and SDK49. The solution is to correct the namespace manually. I mention this here because I figure many are upgrading their Expo SDK because Google is enforcing targeted API Level 33 in a few days.

Detail and credit

leons1767 avatar Aug 27 '23 13:08 leons1767

Thank you @megacherry and @jasonpeinko

rafakwolf avatar Aug 27 '23 20:08 rafakwolf

Ouch, sorry guys, missed that... I'll read whether we can avoid extra step.

Strange that Expo is able to find one lib and fails to find another

divanc avatar Aug 29 '23 10:08 divanc

I was able to solve it via app.json. Add under plugins expo-build-properties:

[
  "expo-build-properties",
  {
    "android": {
      "extraMavenRepos": [
        "../../node_modules/react-native-adapty/lib/android/localMaven"
      ]
    },
  }
],

If you are in a monorepo, then use "$rootDir/../../../node_modules/react-native-adapty/lib/android/localMaven" instead of the other path. :)

This solved my issue.

erenkulaksiz avatar Aug 25 '24 17:08 erenkulaksiz