React-native-share: Could not find method compileOnly() for arguments when upgrade 1.0.27 to 1.1.0

Created on 2 Aug 2018  路  3Comments  路  Source: react-native-share/react-native-share

Steps to reproduce

  1. upgrade react-native-share version 1.0.27 to 1.1.0
  2. run : react-native run-android
  3. got error:
    Could not find method compileOnly() for arguments [com.facebook.react:react-native:+]

Expected behaviour

Success build will occur.

Actual behaviour

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/shouhuasun/dev/image-words/mobile/node_modules/react-native-share/android/build.gradle' line: 53

  • What went wrong:
    A problem occurred evaluating project ':react-native-share'.

    Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Environment

  • React Native version: 0.56.0
  • React Native platform + platform version:
    OS: macOS High Sierra 10.13.6
    Android:8.0

react-native-share

Version: 1.1.0

android

Most helpful comment

Hi, this is because of your Gradle. you must use Gradle 3+. Please upgrade your gradle. If you are using latest React native 0.56.0 then do these basic steps:
Update gradle version in android/gradle/wrapper/gradle-wrapper.properties :

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Modify android/build.gradle under dependencies:

 classpath 'com.android.tools.build:gradle:3.1.0'

All 3 comments

Hi, this is because of your Gradle. you must use Gradle 3+. Please upgrade your gradle. If you are using latest React native 0.56.0 then do these basic steps:
Update gradle version in android/gradle/wrapper/gradle-wrapper.properties :

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Modify android/build.gradle under dependencies:

 classpath 'com.android.tools.build:gradle:3.1.0'

+1 on this issue. Tried to follow @yeomann steps, didn't work.

Hi @luco thank for comment. i have produced a sample repo, you can check all the working configs and settings.
https://github.com/yeomann/react-native-share-android-test

Please note following that

you have neccessary tools installed for android such as SDK and build tools with 27
as mentioned in build.gradle

  buildToolsVersion = "27.0.3"
  minSdkVersion = 19
  compileSdkVersion = 27
  targetSdkVersion = 27
  supportLibVersion = "27.1.1"


Also note that i am using react-native 0.56.0 that is latest for now, with upgraded gradle 3+ with 4.4 distributions distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MbF-Sathya picture MbF-Sathya  路  4Comments

vikjovanov picture vikjovanov  路  3Comments

a-koka picture a-koka  路  3Comments

ruimfernandes picture ruimfernandes  路  4Comments

saifkamaal picture saifkamaal  路  3Comments