0

I imported a project into Android Studio, but the project is not getting built. the error message I get is:

Error:(20, 0) Could not find method compile() for arguments [file collection]  
on object of type 
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

<a href="openFile:C:\Users\xxx\AndroidStudioProjects\WSAppAndroid 
\build.gradle">Open File</a>

As shown in image-1 posted below, in gradle.build (project) I have these libraries in the dependencies section.

I googled how to solve this issue and among the posts I found was this one which tackles the same problem. But the accepted answer does not solve the problem i have.

As an attempt to solve this issue, can I use compile instead of compile files in build.gradle? how it can be done? my question is

image-1

enter image description here

build.gradle (project):

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

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
}
}
allprojects {
repositories {
    jcenter()
    mavenCentral()
}
}

dependencies {
compile files('gradle/wrapper/gradle-wrapper.jar')
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile 'com.android.support:support-v4:25.2.0'
}

compile-on-org-gradle-api-internal-artifacts-dsl-depen/33991915#33991915

LetsamrIt
  • 3,653
  • 7
  • 39
  • 72

3 Answers3

1

compile has been replaced by implementation in newer version of gradle, replace compile with implementation and compile group with implmenetation group in your build.gradle file.

developerick
  • 3,164
  • 4
  • 35
  • 43
0

If you want to add your local jars as dependencies I would suggest.

Adding apply plugin: 'java'

Adding your folder as a repository

repositories {
   flatDir {
       dirs 'libs'
   }
}

then add them to the dependencies.

dependencies {
   compile name: 'whatever'
}

another thing is why do you add the Gradle wrapper as a dependency?

LazerBanana
  • 6,385
  • 3
  • 25
  • 45
0

well the problem here is that in the project uses local libs , so you need to add compile fileTree(include: ['*.jar'], dir: 'libs') now gradle will import the jars located in libs folder.

so you will have

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('gradle/wrapper/gradle-wrapper.jar')
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile 'com.android.support:support-v4:25.2.0'
}
Oussema Aroua
  • 5,073
  • 1
  • 25
  • 44