When trying to create a development build using ex...
# community-support
d
When trying to create a development build using expo, I get this error: ✖️ Build failed 🤖 Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew" (https://expo.dev/accounts/danieljvargas/projects/Tesis/builds/38108ef5-955d-4d22-9845-429f2ce04d27#run-gradlew) phase for more information. There I see: FAILURE: Build failed with an exception. * Where: Build file '/home/expo/workingdir/build/node_modules/react-native-picker/android/build.gradle' line: 25 * What went wrong: A problem occurred evaluating project ':react-native-picker'.
Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
The file in question being: `buildscript { ext.safeExtGet = {prop, fallback -> rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.buildG7.2.0") } } def getExtOrDefault(name) { return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativePicker_' + name] } def getExtOrIntegerDefault(name) { return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativePicker_' + name]).toInteger() } def resolveReactNativeDirectory() { def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) if (reactNativeLocation != null) { return file(reactNativeLocation) } // monorepo workaround // react-native can be hoisted or in project's own node_modules def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native") if (reactNativeFromProjectNodeModules.exists()) { return reactNativeFromProjectNodeModules } def reactNativeFromNodeModulesWithPicker = file("${projectDir}/../../../react-native") if (reactNativeFromNodeModulesWithPicker.exists()) { return reactNativeFromNodeModulesWithPicker } throw new Exception( "[react-native-picker] Unable to resolve react-native location in " + "node_modules. You should add project extension property (in app/build.gradle) " + "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native." ) } def getReactNativeMinorVersion() { def REACT_NATIVE_DIR = resolveReactNativeDirectory() def reactProperties = new Properties() file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) } def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME") def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger() return REACT_NATIVE_MINOR_VERSION } def isNewArchitectureEnabled() { // To opt-in for the New Architecture, you can either: // - Set
newArchEnabled
to true inside the
gradle.properties
file // - Invoke gradle with
-newArchEnabled=true
// - Set an environment variable
ORG_GRADLE_PROJECT_newArchEnabled=true
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" } apply plugin: 'com.android.library' if (isNewArchitectureEnabled()) { apply plugin: "com.facebook.react" } android { def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION if (agpVersion.tokenize('.')[0].toInteger() >= 7) { namespace "com.reactnativecommunity.picker" } compileSdkVersion safeExtGet('compileSdkVersion', 31) defaultConfig { minSdkVersion safeExtGet('minSdkVersion', 21) targetSdkVersion safeExtGet('targetSdkVersion', 31) vectorDrawables.useSupportLibrary=getExtOrDefault('vector_drawable_use_support_library') buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()) } sourceSets.main { java { if (isNewArchitectureEnabled()) { srcDirs += [ "src/fabric/java", ] } else { srcDirs += [ "src/paper/java", ] } } } } repositories { maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$projectDir/../node_modules/react-native/android" } google() mavenCentral() } dependencies { if (isNewArchitectureEnabled() && getReactNativeMinorVersion() < 71) { implementation project(":ReactAndroid") } else { implementation 'com.facebook.reactreact native+' } }` I dont see what is the problem in line 25
🧵 2
v
Please don't post such walls of text to the channel, that makes following the channel harder, especially on mobile. Better post a short summary and then additional information like the build script in the thread. Speaking about the build script, what you posted is not what it complains about, hence you don't get what the problem is in line 25. The build script in question is https://github.com/beefe/react-native-picker/blob/ceb20cbd077dd8afc25e3cbe6cd1d4c59d6b6b93/android/build.gradle. That project is not yet compatible with Gradle 7+. It already merged a fix for it but did not release it. To me that is a strong sign that lib is unmaintained. Either use an older Gradle version, or make the maintainer release a fix, or use a fork if available, or use a different lib that is maintained.