Error:(22,0) Gradle DSL method not found: 'compile()' - android

Hi guys I'm having a problem Gradle DSL method not found: 'compile()'. Most of the discussions I read suggest that I add compile 'com.android.support:support-v4:21.+' to individual's module build file and in my case the compile 'com.android.support:support-v4:21.+' is already there. If I remove the one I added on the top most level build file I get this error (Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2).
Please help, here are my gradle files:
// 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:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile 'com.android.support:support-v4:21.+'
}
Gradle file under App folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.ntokozo.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Thank you.

Remove the dependencies block from the top level build.gradle file.
dependencies {
compile 'com.android.support:support-v4:21.+'
}
Also update your sdk files.

Related

How to add TIKA into build.gradle using android studio?

I'm trying to put Apache Tika into my project.
But it returns error, unfortunately, I couldn't solve this problem by myself.
How can I put Apache Tika using android studio?
Error:(27, 0) Gradle DSL method not found: 'runtime()'
Possible causes:The project 'AudioTest' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test.audiotest"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
runtime 'org.apache.tika:tika-parsers:1.13'
}
this is my build.gradle module:app
// 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.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is my build.gradle project:AudioTest
change
runtime 'org.apache.tika:tika-parsers:1.13'
to
compile 'org.apache.tika:tika-parsers:1.13'

Add parse UI-widget but Gradle DSL Method not found: compile()

I'm trying to add the Parse UI widget by following the guide on https://github.com/ParsePlatform/ParseUI-Android. However, when I do that, I get an error that my project may be using a version of Gradle that does not contain the method and that the build file might be missing the Gradle plugin.
This is my Gradle module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.joakim.boken"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*jar')
}
// Module dependency on ParseUI libraries sources
compile project(':ParseUI-Widget')
// Uncomment if using Facebook Login (optional Maven dependency)
// compile 'com.facebook.android:facebook-android-sdk:4.0.1'
// compile files('YOUR_PROJECT_LIBS_PATH/ParseFacebookUtilsV4-1.10.0.jar')
and this is my 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:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Anybody know what I need to add or erase to get it working? I tried answers to similar questions, but so far nothing worked..
I'm not sure if it mattered that I downloaded the ZIP instead of cloning the repository?
You have to move this line inside the dependencies block:
compile project(':ParseUI-Widget')
It should be:
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*jar')
// Module dependency on ParseUI libraries sources
compile project(':ParseUI-Widget')
}

Error:(20, 0) Gradle DSL method not found: 'compile()'

I have looked at other related but none seems to Solve my Problem in Gradle.
Here is my Build Gradle (Module App )
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.abdul_000.project"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v13.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
}
// 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:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
} apply plugin: 'application'
allprojects {
repositories {
jcenter()
}
}
}
The are it gives me
"Error:(20, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Project' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin"
What am I doing wrong ?
You cannot add compile dependencies to global build.gradle file. Removing the second dependencies block in your global build.gradle file would fix the error.

Gradle DSL method not found: compile()

I use the IDE android studio 1.0.2 version.
I get the following error:
Gradle DSL method not found: 'compile()'
Error(0,9): The project 'MiarrayAdapter' may be using a version
of Gradle that does not contain the method
the built file may be missing a Gradle plugin
My file build.gradle is:
// 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:1.0.0'
compile 'com.android.support:appcompat-v7:+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I´ve other file build.gradle (Module app), the code is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.cursoandroid.miarrayadapter"
minSdkVersion 6
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:+'
}
allprojects {
repositories {
jcenter()
}
}
Remove the following from your top-level build.gradle:
compile 'com.android.support:appcompat-v7:+'
and also note the comment there:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Android Studio 1.0.0 - Failed to find butterknife:6.0.0

I am using Android Studio 1.0.0. I am trying to add dependencies of butterknife.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.google.android.gms:play-services:6.1.11'
compile 'com.android.support:recyclerview-v7:21.0.2'
}
But i am getting the following Gradle error:
Error:Failed to find: com.jakewharton:butterknife:6.0.0
I had the same problem! Finally, when I tried to clean project I got more specific gradle error: No cached version of com.jakewharton:butterknife:6.0.0 available for offline mode. So the problem was that gradle offline mode was enabled! All you need to do is uncheck Settings -> Gradle -> Offline work ...
I added, below three lines, it got fixed. Thanks everyone.
repositories {
mavenCentral()
}
I tried in my build.gradle, it works.
In the root build.gradle. You can try put repositories { mavenCentral() } outside the buildscript, then it would work.
EDIT
build.gradle in app
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.jakewharton:butterknife:6.0.0'
}
build.gradle in root
// 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:1.0.0-rc4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
settings.gradle
include ':app'
Go to your project dir.
./gradlew clean
This downloaded the dependencies and resolved "Failed to find:" dependenices issue

Categories

Resources