I am using Android Studio 1.4.1. any project when i open it in Android Studio, all the classes of the project are loaded correctly and the projects work fine.
the problem is when i try to opn a specific project named "EcoAssistant_03", i receive the following message:
Error:(22, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'EcoAssistant_03' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I do not know what is wrong whith project, and i do not know how to get it running correctly.
please have a look at the build.gradle files posted below, and let me know how to get it running
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
}
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.com.ecoassistant_03"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/Jama-1.0.3.jar')
compile files('libs/drivingEfficiencyModuleRunnable_00_out.jar')
}
update:
Your error tells you the exact problem.
Gradle DSL method not found: 'android()'
Remove this android section from the top level build.gradle. The Android plugin hasn't been applied to that file.
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
}
That'll fix the problem, but here's some notes
These lines aren't necessary. You already are compiling them with the first line of the dependencies section
compile files('libs/Jama-1.0.3.jar')
compile files('libs/drivingEfficiencyModuleRunnable_00_out.jar')
And this line compiles the two that follow it, so those are not necessary either
compile 'com.android.support:design:23.1.1'
In other words, this is all you need to build the app
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.1.1'
}
Related
I keep getting this error when I try to run my app in Android Studio
Error:(20, 0) Could not find method android() for arguments [build_cmskf0wjjh0skzgqp1j9qzll2$_run_closure2#29a3fe65] on root project 'pomppyapp' of type org.gradle.api.Project.
Open File
This is my build.gradle (Project: pomppyapp)
// 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.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files 2.3.3
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
dependencies {
}
Also another file there called build.gradle (Module: app) with the following:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.pomppyapp.com"
minSdkVersion 15
targetSdkVersion 23
versionCode 12
versionName '1.6'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.android.tools.build:gradle:2.3.0'
}
apply plugin: 'com.google.gms.google-services'
Any help would be grateful, thanks in advance.
I think, this section in your top gradle build file is wrong:
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
It should stay only in project gradle.build file (in this case for module :app)
You should remove these following lines from project level build.gradle because there is no android gradle plugin applied in it.
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
dependencies {
}
It should be only in the module level gradle files in which android gradle plugin has been applied. :app in this case, in which android application gradle plugin has been applied (apply plugin: 'com.android.application')
This question already has answers here:
Error: Gradle DSL method not found: compile()
(2 answers)
Closed 5 years ago.
I am stucked at this problem since 2-3 hours. I tried many solution from similar question but none is working. The gradle build was working fine but after changing min sdk level from 23 to 17 android studio started giving me this error.
Error:(32, 0) Gradle DSL method not found: 'compile()'Possible causes:
The project 'android' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.3 and sync project
The project 'android' 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
Below are my gradle files:
build.gradle(project:android)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.google.transporttracker"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
resValue "string", "build_transport_id", (project.findProperty("build_transport_id") ?: "")
resValue "string", "build_email", (project.findProperty("build_email") ?: "")
resValue "string", "build_password", (project.findProperty("build_password") ?: "")
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
productFlavors {
}
}
ext {
support = '23.2.0'
playServices = '10.2.4'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:$support" compile "com.android.support:cardview-v7:$support" compile "com.android.support:design:$support" compile "com.google.android.gms:play-services-gcm:$playServices" compile "com.google.android.gms:play-services-location:$playServices" compile "com.google.firebase:firebase-core:$playServices" compile "com.google.firebase:firebase-auth:$playServices" compile "com.google.firebase:firebase-config:$playServices" compile "com.google.firebase:firebase-crash:$playServices" compile "com.google.firebase:firebase-database:$playServices" compile 'com.android.support.constraint:constraint-layout:1.0.2'
classpath 'com.google.gms:google-services:3.0.0'
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The problem is inside the dependencies closure: You can't write multiple compile statements in one line. Just write each compile statement in a separate line, than it will work.
I think it's a bug with auto-formatting when you use variables for the dependency versions and therefore wrap the dependencies in double quotes instead of single quotes.
I updated my android studio and my gradle will not sync
issues it gives me these errors. Im also using firebase as for authorization and database.I have tried deleting the gradle files and rebuilding but that didnt work. any suggestions would be appreciated.
Failed to resolve .com.android.support:support-v4:25.2.0
Failed to resolve com.android.support.test.espresso:espresso-core:2.2.2
Failed to resolve com.android.support:appcompat-v4:25.3.1
Failed to resolve com.android.support:mediarouter-V7:25.2.0
here is the build gradle for the project
// 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.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here is my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.example.dude.sportspicks518"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.android.support:appcompat-v4:25.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.2.6'
}
apply plugin: 'com.google.gms.google-services'
several way to try
Invalidate Cache/Restart AS
Clean Project and Rebuild
Update "Google Repository" and "Android Support repository" in the Android SDK Manager.
if not working, then If you are trying to get the support repository, this is the correct import:
compile "com.android.support:support-v4:25.3.1"
If your compile api isn't 25, change the version to the latest with your compile api.
Android Studio should give you a yellow warning if you are using incompatible version. just hover it and use the suggestion given
P/s: Please please dont use com.google.android.gms:play-services.. it very heavy dex method count
I get an error after adding a Simperium Module Application code to my application. It gives me Gradle sync failed: Gradle DSL method not found: 'gitVersion()' error. How can I fix it?
build.gradle code here:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sdn.com.sd"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile 'com.android.support:support-v13:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile project(':SDUtils')
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile project(':SDAnalytics')
compile project(':SDEditor')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile files('libs/gcm.jar')
compile project(':SDNetworking')
compile project(':PassCode')
compile files('libs/eventbus-3.0.0-beta1.jar')
compile project(':Simperium')
}
Gradle Sync message output:
Error:(13, 0) Gradle DSL method not found: 'gitVersion()'
Possible causes:<ul><li>The project 'SD' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
Thanks in advance for your helps.
You are adding a module in your project (as you've explained in your comment)
you can have the look of the Simperium module project at this link. github.com/Simperium/simperium-android I had simply added this project as a module in my application
Gradle is trying to process the build.gradle inside the Simperium module.
https://github.com/Simperium/simperium-android/blob/develop/build.gradle
Inside this file there are some functions defined in the root/build.gradle of the Simperium-project.
def gitHash() {..}
def gitDescribe() {..}
def gitVersion(){..}
You have to copy these functions inside your top-level build.gradle file.
root
|--app
|----build.gradle
|--build.gradle <- here
|--settings.gradle
I'm new to Android Studio, I've been using Eclipse for about 2 years. I've trying understanding these solutions.
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
Gradle DSL method not found: 'compile()'
I just can't get it to work.
Here's what it says..
Error:(17, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'clxxxii - PMv5' 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
and
'dependencies' cannot be applied to '(groovy.lang.Closure)' less... (⌘F1)
This inspection reports assignments with incompatible types
Here's the file where it's giving an error
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0' }
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
apply plugin: 'announce'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.+'
}
And based on the other questions, you may need this too.
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/FlurryAnalytics_3.3.0.jar')
compile files('libs/heyzap-ads-sdk.jar')
compile files('libs/HomeBaseSDK2.2.jar')
compile files('libs/placed-persistent-sdk-1.10.jar')
compile files('libs/revmob-6.7.0.jar')
}
Can someone help me understand what the problem is, and why it's happening?
This might not fully answer your question but maybe you can get your project running.
These dependencies dont belong in your first build.gradle file :
dependencies {
apply plugin: 'announce'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.+'
}
Your dependencies in your Project build.gradle should look like this, the comment is generated by the IDE and tells you not to put your app dependencies here :
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Move them to the /app/build.gradle file, and I modified your file a little so its up to date to the currently newest version of buildTools etc. You might have to download some of them from your SDK Manager if you dont already have :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "your.package.name"
minSdkVersion 8
targetSdkVersion 22
}
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:22.0.0'
compile 'com.android.support:support-v4:+'
compile files('libs/FlurryAnalytics_3.3.0.jar')
compile files('libs/heyzap-ads-sdk.jar')
compile files('libs/HomeBaseSDK2.2.jar')
compile files('libs/placed-persistent-sdk-1.10.jar')
compile files('libs/revmob-6.7.0.jar')
}