walterholohan / react-native-crisp-chat-sdk

React-Native bridge for Crisp Chat iOS and Android SDK's
MIT License
71 stars 26 forks source link

[Android] from jcenter to maven #39

Closed mlecoq closed 2 years ago

mlecoq commented 3 years ago

In RN 0.65, jcenter is removed in favor of maven

I have the following issue with crisp sdk:

Could not find com.google.android.exoplayer:exoplayer:2.13.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - file:/Users/mlecoq/.m2/repository/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - https://customers.pspdfkit.com/maven/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - file:/Users/mlecoq/Developer/archireport/dev/archireport_mobile/node_modules/react-native/android/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - file:/Users/mlecoq/Developer/archireport/dev/archireport_mobile/node_modules/jsc-android/dist/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - https://dl.google.com/dl/android/maven2/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - https://maven.google.com/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
       - https://www.jitpack.io/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
     Required by:
         project :app > im.crisp:crisp-sdk:1.0.4
predescu commented 3 years ago

I have the same issue. @mlecoq , did you find any workaround?

mlecoq commented 3 years ago

I have put back jcenter()

walterholohan commented 3 years ago

I just had a look at the official Crisp Android SDK docs (https://github.com/crisp-im/crisp-sdk-android#2-setup-repos) and it looks like we need to include JCenter. I will keep an eye on this repo and hopefully, they release an update in the future.

walterholohan commented 3 years ago

Ive updated the README with this, and also released a new version that includes the latest versions of the Crisp iOS and Android SDK's

Pandazaur commented 2 years ago

I added jcenter() to both build.gradle and app/build.gradle but no changes. It doesn't work on my app

akinlekan28 commented 2 years ago

I added jcenter() to both build.gradle and app/build.gradle but no changes. It doesn't work on my app

https://github.com/walterholohan/react-native-crisp-chat-sdk/issues/35#issuecomment-952201990

runna-app commented 2 years ago

What error messages are you getting? Can you check that you build.gradle and app/build.gradle match what's in the example folder?

Pandazaur commented 2 years ago

EDIT: I found the problem ! In the android/app/build.gradle:

allprojects {
    repositories {
       // I had this block, but I also needed to add `jcenter()` alone.
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
        jcenter() // <-- added this line
    }
}

I added jcenter() to both build.gradle and app/build.gradle but no changes. It doesn't work on my app

https://github.com/walterholohan/react-native-crisp-chat-sdk/issues/35#issuecomment-952201990

I'm using a more recent version of gradle.

Here are some more informations about my error:

android/build.gradle

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

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        supportLibVersion = "29.0.0"
        playServicesVersion = "17.0.0"
        androidMapsUtilsVersion = "2.2.0"
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath("com.bugsnag:bugsnag-android-gradle-plugin:5.+")
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter() {
            content {
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }
        maven { url 'https://www.jitpack.io' }
    }
}

android/app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

project.ext.envConfigFiles = [
    debug: ".env",
    releaseStaging: ".env.staging",
    release: ".env.production",

    anothercustombuild: ".env",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

project.ext.react = [
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply plugin: "com.bugsnag.android.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc-intl:+'
def enableHermes = project.ext.react.get("enableHermes", false);
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")

android {
    ndkVersion rootProject.ext.ndkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId "com.coobers.frenchfounders"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "7.0.0"
        resValue "string", "build_config_package", "com.coobers.frenchfounders"
        missingDimensionStrategy 'react-native-camera', 'general'
        manifestPlaceholders = [
            onesignal_app_id: 'xxxx',
            onesignal_google_project_number: 'REMOTE',
        ]
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }

        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            if (nativeArchitectures) {
                ndk {
                    abiFilters nativeArchitectures.split(',')
                }
            }
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            resValue "string", "CodePushDeploymentKey", '"xxxx"'
        }

        releaseStaging {
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            resValue "string", "CodePushDeploymentKey", '"xxxx"'
            matchingFallbacks = ['release']
        }

        release {
            signingConfig signingConfigs.release
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            resValue "string", "CodePushDeploymentKey", '"xxxx"'
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }

        }
    }
}

dependencies {
    implementation project(':react-native-incall-manager')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation 'im.crisp:crisp-sdk:1.0.7'
    implementation 'androidx.multidex:multidex:2.0.1'

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.google.android.gms:play-services-auth:19.2.0'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.implementation
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

bugsnag {
  uploadReactNativeMappings = true
}

The error message is:

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.google.android.exoplayer:exoplayer:2.13.0.
     Searched in the following locations:
       - file:/Users/alexandreborel/FrenchFounders/app-v4/node_modules/@bugsnag/react-native/android/com/google/android/exoplayer/exoplayer/2.13.0/exoplayer-2.13.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app > im.crisp:crisp-sdk:1.0.7
walterholohan commented 2 years ago

I just released a new version https://github.com/walterholohan/react-native-crisp-chat-sdk/releases/tag/v0.9.1 that should fix the maven issues

mlecoq commented 2 years ago

jcenter is still needed for com.google.android.exoplayer:exoplayer:2.13.0

walterholohan commented 2 years ago

@mlecoq I just published 0.10.0 which removes the jcenter() dependency. I think it should be ok for us to remove now