Closed dexterowy closed 2 years ago
I have same problem.
+1
++
++
Credits to: @karunais13 🥳
Follow this PR #116 And you would get the error
A problem occurred configuring project ':react-native-month-year-picker'. Configuration with name 'compile' not found.
Fix this issue at this line by replacing
Line 112
with
project.getConfigurations().getByName('implementation').setCanBeResolved(true)
classpath += files(project.getConfigurations().getByName('implementation').asList())
Tested on: Device: Android Emulator Version: API 30 (R)
I replaced
classpath += files(project.getConfigures().getByName('compile')".AsList()
with
project.getConfigures(.)getByName('implementation')".setCanBeResolved(true)
classpath += files(project.getConfigurations().getByName('implementation').atList())
But, the following error occurs.
A problem occurred configuring project ':react-native-month-year-picker'. Could not find method mavenDeployer() for arguments [build_cpjg07lq2uvseed0dckyuidwc$_run_closure4$_closure15$_closure17@33bafdd9] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
Here's the code.
node_modules/react-native-month-year-picker/android/build.gradle
// 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
def DEFAULT_COMPILE_SDK_VERSION = 29
def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3'
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 29
def DEFAULT_NDK_VERSION = '20.1.5948944'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
buildscript {
// 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:4.1.0'
}
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
ndkVersion safeExtGet('ndkVersion', DEFAULT_NDK_VERSION)
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
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
}
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.gusparis.monthpicker"
description packageJson.description
url packageJson.repository.baseUrl
licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
developers {
developer {
id packageJson.author.username
name packageJson.author.name
}
}
}
}
afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
project.getConfigurations().getByName('implementation').setCanBeResolved(true)
classpath += files(project.getConfigurations().getByName('implementation').asList())
include '**/*.java'
}
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocJar
}
task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
}
Credits to: @karunais13 🥳
- Follow this PR fix maven compile error #116 And you would get the error
A problem occurred configuring project ':react-native-month-year-picker'. Configuration with name 'compile' not found.
- Fix this issue at this line by replacing
Line 112
with
project.getConfigurations().getByName('implementation').setCanBeResolved(true) classpath += files(project.getConfigurations().getByName('implementation').asList())
- Then rebuild the project
Tested on: Device: Android Emulator Version: API 30 (R)
in my case, the problem was the opposite I had to comment
project.getConfigurations().getByName('implementation').setCanBeResolved(true) classpath += files(project.getConfigurations().getByName('implementation').asList())
and all works fine ... I think that PR broke something else
Fixed on #140. Can you guys check?
React Native
0.67.x
now uses Gradle 7 which has removedmaven
in favor ofmaven-publish
.Library is not building anymore.