Open nixolas1 opened 2 years ago
I'm experiencing the same issue
I found a solution... it seems you're right with the maven plugin deprecation. For now what I've done is used 0.66.1 version of React-Native which uses a downgraded version of Gradle (it fixed it... just make sure you have Java 8 or something set as your path and not Java 17)... Android seems to have problems with it :) Worked for me
// android/build.gradle
// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
// https://www.cognizantsoftvision.com/blog/creating-an-android-native-module-for-react-native/
def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 19
def DEFAULT_TARGET_SDK_VERSION = 28
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
buildscript {
ext.kotlin_version = '1.4.10'
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
repositories {
// ref: https://www.baeldung.com/maven-local-repository
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()
}
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.mapbox.navigation:core:1.5.0'
implementation 'com.mapbox.navigation:ui:1.5.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.homee.mapboxnavigation"
description packageJson.description
url packageJson.repository.baseUrl
licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
}
}
afterEvaluate { project ->
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}
}
This is due to Gradle 7 removed the maven plugin. This issue will occur if you use gradle 7 in your project. I fixed the problem by downgrading to Gradle 6.9.
The gradle version can be found in android/gradle/wrapper/gradle-wrapper.properties
I solved this by going into "\node_modules\@homee\react-native-mapbox-navigation\android" and replacing build.gradle with this:
// android/build.gradle
// based on: // // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle // original location: // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle // // https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle // original location: // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
// https://www.cognizantsoftvision.com/blog/creating-an-android-native-module-for-react-native/
def DEFAULT_COMPILE_SDK_VERSION = 28 def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' def DEFAULT_MIN_SDK_VERSION = 19 def DEFAULT_TARGET_SDK_VERSION = 28
def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback }
apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'maven-publish'
buildscript { ext.kotlin_version = '1.4.10' // The Android Gradle plugin is only required when opening the android folder stand-alone. // This avoids unnecessary downloads and potential conflicts when the library is included as a // module dependency in an application project. // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies if (project == rootProject) { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' } }
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'maven-publish'
android { compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) versionCode 1 versionName "1.0" } lintOptions { abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } }
repositories { // ref: https://www.baeldung.com/maven-local-repository 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() }
dependencies { //noinspection GradleDynamicVersion implementation 'com.facebook.react:react-native:+' // From node_modules implementation 'com.mapbox.navigation:core:1.5.0' implementation 'com.mapbox.navigation:ui:1.5.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }
def configureReactNativePom(def pom) { def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.homee.mapboxnavigation"
description packageJson.description
url packageJson.repository.baseUrl
licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
}
}
task androidSourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs }
afterEvaluate { publishing { publications { release(MavenPublication) { from components.release // Add additional sourcesJar to artifacts artifact(androidSourcesJar) } } repositories { maven { url = mavenLocal().url } } } }
When I try to do add your code to the build.graddle file in the node modules I get this error "Task :homee_react-native-mapbox-navigation:compileDebugKotlin FAILED"
Hi @OleTheDev your patch worked but had the same issue as @jamesvovos, updating the kotlin version to 1.6.0 in the @home/react-native-mapbox-navigation
build.gradle worked to fix it! thanks for the help!
Hi, How to resolve this when using gradle version 8.0 ? I tried all your solutions but still no lucky
Hi, I get two errors when building release 2.0.0 with react native 0.67.3, for android:
The usage of maven plugin is deprecated, I think.