无法在对象上找到参数 [project ':model'] 的方法 api()

Waq*_*han 10 android gradle

错误:(36, 0) 无法在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找到参数 [project ':model'] 的方法 api()

请帮我。

这是我的 build.gradle 文件。

apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
 applicationId "com.manafzar.mytaxi.driver"
 minSdkVersion 16
 targetSdkVersion 26
 versionCode 23
 versionName "2.0.3"
 multiDexEnabled true
 vectorDrawables.useSupportLibrary = true
 javaCompileOptions {
    annotationProcessorOptions {
    arguments = [eventBusIndex: 
   'com.manafzar.mytaxi.driver.DriverEventBusIndex']
  }
 }
}
buildTypes {
 release {
   minifyEnabled false
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 
      'proguard-rules.pro'
  }
}
dataBinding {
  enabled = true
  }
}

dependencies {
   annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.0.1'
   api project(':model')
   api 'com.google.maps.android:android-maps-utils:0.5'
   api 'com.diogobernardino:williamchart:2.5.0'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

and*_*dre 16

从 Gradle 5.0 迁移到 Gralde 6.0.x 时,我遇到了同样的问题。

正如@ShadowMan 提到的,问题是缺少java-library引入该api方法的插件。

在您的build.gradle文件中,您应该包括:

plugins {
    id 'java-library'
}
Run Code Online (Sandbox Code Playgroud)

更多信息可以在这里找到:https : //docs.gradle.org/current/userguide/java_library_plugin.html


Pat*_*k R -4

请在依赖项标签中添加“compile”而不是“api”。并请在您的主 bu​​ild.gradle 文件中添加以下代码:

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)