Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method api() for arguments [project ':model'] on object of

Tags:

android

gradle

Error:(36, 0) Could not find method api() for arguments [project ':model'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Please help me.

This is my build.gradle file.

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'
like image 634
Waqas Khan Avatar asked Dec 02 '17 19:12

Waqas Khan


1 Answers

I ran into the same issue when migrating from Gradle 5.0 to Gralde 6.0.x.

As @ShadowMan mentioned, the issue was missing the java-library plugin which introduces the api method.

In your build.gradle file you should include:

plugins {
    id 'java-library'
}

More info can be found here: https://docs.gradle.org/current/userguide/java_library_plugin.html

like image 69
andre Avatar answered Oct 31 '22 12:10

andre