getting
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
Where:
Build file '/Users/chandrasekar/workspace/hybrid-consumer-app/node_modules/react-native-ble-plx/android/build.gradle' line: 20
What went wrong:
A problem occurred evaluating project ':react-native-ble-plx'.
Failed to apply plugin [id 'groovyx.android']
Could not create an instance of type groovyx.internal.DefaultAndroidGroovySourceSet.
Could not find matching constructor for: org.gradle.api.internal.file.DefaultSourceDirectorySet(org.codehaus.groovy.runtime.GStringImpl, org.gradle.api.internal.file.BaseDirFileResolver, org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory)
Try:
What went wrong:
A problem occurred configuring project ':react-native-ble-plx'.
compileSdkVersion is not specified.
Try:
Get more help at https://help.gradle.org
BUILD FAILED in 4s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (/Users/chandrasekar/workspace/hybrid-consumer-app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
In android/app/build.gradle
add multiDexEnabled true
android {
....
defaultConfig {
...
multiDexEnabled true
}
@vaqif14 still the same issue.
@chandrasekarvogo Same problem here.
According to
https://github.com/groovy/groovy-android-gradle-plugin/commit/a336b37fed8d9dbad1087fe010c6a03deb8fdad1
The problem seemed to be coming from groovyx rather than RN / react-native-ble-plx.
Same issue here, I just spotted it after migrating to 0.62.0.
@TheHothihi
0.62 bring
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
Looks like exactly the issue reported by groovy/groovy-android-gradle-plugin@a336b37
@Cierpliwy @dariuszseweryn Any ideas guys ? Work great when using gradle 5.5
I also got the same error with 0.62.0 today.
Seems like as @ScreamZ pointed out.
Could you guys take a look at it @dariuszseweryn @Cierpliwy ? I really appreciate that.
Same issue here, also on 0.62.0
seems gradle v6.0 support added in Gradle 6 compatibility and release in [email protected]. This library running in older version. upgrading groovy-android-gradle-plugin might help. @Cierpliwy @dariuszseweryn
I also got same issues with RN 0.62
react-native link react-native-ble-plx doesn't work for android.
seems gradle v6.0 support added in Gradle 6 compatibility and release in [email protected]. This library running in older version. upgrading groovy-android-gradle-plugin might help. @Cierpliwy @dariuszseweryn
Could you please point me to a resource to do that?
Downgrading my project to gradle 5.6.4 worked as an interim solution for me. In Android Studio, go to File >> Project Structure. On the project tab change Gradle version to 5.6.4. This modifies gradle/wrapper/gradle-wrapper.properties to have distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip.
Same problem at 0.62
Here is my workaround for those who need this package run with latest react native version 0.62.0
As the problem is pointed out with Gradle version < 6, so we should upgrade the build tool and groovy plugin.
Here is a step by step:
1/ Fork this repository
2/ In android folder, open build.gradle:
Update this code:
buildscript {
repositories {
jcenter()
google() // This for build tool
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0' // Update build tool gradle
classpath 'gradle.plugin.org.codehaus.groovy:groovy-android-gradle-plugin:3.0.0' // Update groovy for gradle 6+
}
}
apply plugin: 'com.android.library'
apply plugin: "org.codehaus.groovy.android" // Update this
2/ Open gradle/wrapper/gradle-wrapper.properties, update this code:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip // You can choose your gradle version 6+
3/ Commit and push the code to Github
4/ Install the package with GitHub packager or you can use npm-link (or yalc) to test it locally.
5/ Do the same thing as the installation document.
Note: This is a workaround for this issue while we wait for the author updates his awesome library.
Note: For IOS, we can keep the same or update MultiplatformBleAdapter to the latest version if you want.
Upvote for this comment if it works for your project.
In a more simple way I solved using a solution very similar to the the previous one (no forks required):
buildscript {
repositories {
jcenter()
google() // This for build tool
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0' // Update build tool gradle
classpath 'gradle.plugin.org.codehaus.groovy:groovy-android-gradle-plugin:3.0.0' // Update groovy for gradle 6+
}
}
apply plugin: 'com.android.library'
apply plugin: "org.codehaus.groovy.android" // Update this
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip // Because I have latest gradle version
I confirm after that I can finally build on Android and now I can use bluetooth plugin APIs.
In a more simple way I solved using a solution very similar to the the previous one (no forks required):
I tried this but it didn't work. Can you provide a repo? Meanwhile, I edited the Gradle files as per @ild-nucleusstudio suggestion and it worked.
Now that there's a pull request available, I just did this to make it work in my project:
cd ..
# Make sure it's ok do write the following repo to the project's parent folder
git clone [email protected]:chancmg/react-native-ble-plx.git
# Go back into the project dir
cd mybleproject
# Install the project from parent dir
npm install $(npm pack ../react-native-ble-plx | tail -1) --save
Method suggested by @strawberry-code works, but to be more clear you should edit build.gradle in node_modules/react-native-ble-plx/android/ and android/gradle/wrapper/gradle-wrapper.properties in your project directory.
Bear in mind, this is VERY temporary solution, all the changes in node_modules will be erased after the update and whatnot.
Downgrading my project to gradle 5.6.4 worked as an interim solution for me. In Android Studio, go to File >> Project Structure. On the project tab change Gradle version to 5.6.4. This modifies
gradle/wrapper/gradle-wrapper.propertiesto havedistributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip.
Downgrading solution worked for me. Anyhow, waiting to get the plugin being supported with Gradle 6.
Thanks馃檹馃徎
Please check version 2.0.0. The issue should be solved.
I can confirm that it works on
"react-native": "0.62.2",
"react-native-ble-plx": "^2.0.0",
Glad to hear that.
Most helpful comment
Here is my workaround for those who need this package run with latest react native version 0.62.0
As the problem is pointed out with Gradle version < 6, so we should upgrade the build tool and groovy plugin.
Here is a step by step:
1/ Fork this repository
2/ In android folder, open build.gradle:
Update this code:
2/ Open gradle/wrapper/gradle-wrapper.properties, update this code:
3/ Commit and push the code to Github
4/ Install the package with GitHub packager or you can use npm-link (or yalc) to test it locally.
5/ Do the same thing as the installation document.
Note: This is a workaround for this issue while we wait for the author updates his awesome library.
Note: For IOS, we can keep the same or update MultiplatformBleAdapter to the latest version if you want.
Upvote for this comment if it works for your project.