【问题标题】:Could not find method compile() for arguments [project ':react-native-sqlite']找不到参数 [project ':react-native-sqlite'] 的方法 compile()
【发布时间】:2017-03-04 12:12:09
【问题描述】:

react-native-cli: 2.0.1 反应原生:0.42.0 npm :3.5.2

我使用本教程在 react native 上安装 sqlite: https://github.com/remobile/react-native-sqlite 当我完成后,我执行了这个命令: react-native run-android 我有这个错误:

Cannot parse yarn version: 0.22
Scanning 547 folders for symlinks in /home/sofiane/projet/sql/node_modules (6ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sofiane/projet/sql/android/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating root project 'sql'.
> Could not find method compile() for arguments [project ':react-native-sqlite'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    compile project(':react-native-sqlite')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

【问题讨论】:

    标签: sqlite ubuntu react-native


    【解决方案1】:

    您应该配置<name-project>/android/app/build.gradle' 而不是<name-project>/android/build.gradle'

    【讨论】:

      【解决方案2】:

      在我的情况下,gradle 文件的结构是问题所在,我不小心复制了 allprojects 会话上的依赖项

      来自:

      // Top-level build file where you can add configuration options common to all sub-projects/modules.
      buildscript {
          repositories {
              jcenter()
              google()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:3.5.2'
      
      
              // NOTE: Do not place your application dependencies here; they belong
              // in the individual module build.gradle files
          }
      }
      
      allprojects {
          repositories {
              jcenter()
              google()
          }
          dependencies { //=> duplicated
              classpath 'com.android.tools.build:gradle:3.5.2'
              classpath "io.realm:realm-gradle-plugin:6.0.1"
          }
      }
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
      
      

      
      buildscript {
          ext.objectboxVersion = '2.1.0'
          repositories {
              jcenter()
              maven {
                  url 'https://maven.google.com/'
                  name 'Google'
              }
              google()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:3.5.1'
              classpath "io.realm:realm-gradle-plugin:6.0.1"
          }
      }
      
      allprojects {
          repositories {
              google()
              jcenter()
          }
      }
      
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
      
      

      希望这对某人有所帮助。

      【讨论】:

        猜你喜欢
        • 2022-07-12
        • 2022-06-19
        • 1970-01-01
        • 2016-04-29
        • 2022-01-23
        • 2017-10-01
        • 1970-01-01
        相关资源
        最近更新 更多