HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
240 stars 68 forks source link

Build breaks with gradle 7.2 (react-native 0.67) #179

Closed peltax closed 1 year ago

peltax commented 2 years ago

Description maven plugin in build.gradle should be changed to use maven-publish plugin.

Expected behavior Build succeeds

Current behavior Build failed

Logs FAILURE: Build failed with an exception.

Build file '.../node_modules/@hmscore/react-native-hms-availability/android/build.gradle' line: 2

Environment Newest HMS react native sdk (availability, location, map), react native 0.67 which uses gradle wrapper 7.2 .

ozcanozgur commented 2 years ago

Hi @peltax

You can try to upgrade agcp version from build.gradle under the android folder.

image

Thank You.

feras-merwas commented 2 years ago

@peltax did you fix the problem

peltax commented 2 years ago

I opted to use react-native-device-info to get hms availability instead of this lib as it was already in use. One less native dependency.

geroale commented 2 years ago

Same issue here. Now we are using react-native-device-info too.

yaroslavnikiforov commented 2 years ago

I have the same issue with: "react-native": "0.67.1", "@hmscore/react-native-hms-account": "^6.1.0-302", "@hmscore/react-native-hms-availability": "^5.2.0-300",

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Build file '/***/app/node_modules/@hmscore/react-native-hms-account/android/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':hmscore_react-native-hms-account'.
> Plugin with id 'maven' not found.

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
        ndkVersion = "21.4.7075529"
        googlePlayServicesAuthVersion = "19.2.0"
        supportLibVersion = "28.0.0"
        kotlinVersion = '1.5.0'
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://developer.huawei.com/repo/' }
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.5'
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath 'com.huawei.agconnect:agcp:1.6.3.300'
    }
}

allprojects {
    repositories {
        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")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
        maven { url 'https://developer.huawei.com/repo/' }
    }
}
gregersn commented 2 years ago

This same problem occurs with react-native-hms-map

topi-identio commented 2 years ago

Any update for this? We're using react-native-hms-location for which I just created a simple patch using patch-package that changes the 'maven' plugin to 'maven-publish', which seems to be enough to get it working with RN 0.67:

diff --git a/node_modules/@hmscore/react-native-hms-location/android/build.gradle b/node_modules/@hmscore/react-native-hms-location/android/build.gradle
index 8216db6..324bddc 100644
--- a/node_modules/@hmscore/react-native-hms-location/android/build.gradle
+++ b/node_modules/@hmscore/react-native-hms-location/android/build.gradle
@@ -11,7 +11,7 @@ buildscript {
 }

 apply plugin: 'com.android.library'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'

 android {
     compileSdkVersion 29
ozcanozgur commented 1 year ago

"maven-publish" issue has been resolved with the latest versions of Availability, Location and Map plugins. You can find it at npm.

React Native Availability Plugin (6.7.0-300) React Native Location Plugin (6.4.0-301) React Native Map Plugin (6.3.1-305)

Thank you for your interest in our plugins.