我尝试使用此命令来安装库react-native-share
npm install react-native-share --save
react-native link react-native-share
但是我得到了这个错误:
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
答案 0 :(得分:0)
解决方案: 我遵循了有关react的地图插件的类似问题的指南。Link to guide
以下步骤对我有用:
1_ Modify android/build.gradle
Add google() inside repositories
buildscript {
repositories {
jcenter()
// add google() here
google()
2_ Update com.android.tools.build.gradle to 3.1.0
buildscript {
repositories {
jcenter()
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.2.3'
// update from 2.2.3 to 3.1.0
classpath 'com.android.tools.build:gradle:3.1.0'
3_在依赖项之后在存储库中添加google()
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
allprojects {
repositories {
mavenLocal()
jcenter()
// add googgle() here
google()
4_ Add android.enableAapt2=false to android/gradle.properties
android.enableAapt2=false // < --- add here
android.useDeprecatedNdk=true
5_ Update gradle version in android/gradle/wrapper/gradle-wrapper.properties
// from version 2.14.1
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
// change to 4.4
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6_ Run react-native run-android. (This might take a while since it’ll be downloading the updated gradle version).