adaptyteam / AdaptySDK-React-Native

React Native SDK for growing in-app subscriptions
https://docs.adapty.io/docs/quickstart
MIT License
128 stars 12 forks source link

expo 49 migration #80

Open rafakwolf opened 1 year ago

rafakwolf commented 1 year ago

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

divanc commented 1 year ago

Hey! Having a look...

jasonpeinko commented 1 year ago

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 commented 1 year ago

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/")
        }
    }
}
rafakwolf commented 1 year ago

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

megacherry commented 1 year ago

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. :)

leons1767 commented 1 year ago

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

rafakwolf commented 1 year ago

Thank you @megacherry and @jasonpeinko

divanc commented 1 year ago

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

erenkulaksiz commented 2 months ago

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.