Gradle project sync failed android studio version 2.2.3 ERROR - android

Well this is my first time using android studio and i keep getting an error message which says:
Gradle sync failed: Could not find method android() for arguments [build_43qncadg6ssgwl9025usbfvce$_run_closure3#c74f8ce] on root project 'MyApplication' of type org.gradle.api.Project.
Consult IDE log for more details
HERE IS THE CODE:
// 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'
// 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 25
buildToolsVersion '25.0.3'
}
dependencies {
}
ERROR: could not find method android() for arguments.
What does this error mean? How can I solve this?

A typical Android project has a root project and a sub project containing the app. It seems you showed the build.gradle of the root project.
The android section would typically go into the sub project's build.gradle.

Related

Trying to add module to project. Gradle DSL method not found: 'versionName()'

I am trying to add a epub reader library to a project I have already created. The library I am trying to add to my project as a moduel is the Folio Reader Library (https://github.com/FolioReader/FolioReader-Android). I have downloaded this library on my computer and have tried adding it through File -> New -> Import Module. However, during the process I received countless errors. My current one is this:
Gradle DSL method not found: 'versionName()'
Possible causes:
The project 'FolioReader-Android-master' 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 3.4.1 and sync project
The project 'FolioReader-Android-master' 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
This file is the file where the dependencies are declared for the Library.
FolioReader-Android-master:
build.gradle file:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
apply from: 'versions.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//moj
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
allprojects {
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error itself states that the problem arises because the project is using a version of the Gradle plug-in may not contain the method. I have updated the version to the newest one, however I still receive this error. Any suggestions on how I can solve this problem?
Problem solved by replacing
versionName 1
with
versionName "1.1"
in the Module level build.gradle file.

:app:mergeDebugAssets > unable to create new thread when updating to Android Studio 3.0.1

I was building a project with a previous version of Android Studio and I decided to update it. So once I updated it I keep getting the same error on application Run (not on clear, not on synching grandle). The error is the following:
Error:Execution failed for task ':app:mergeDebugAssets'. > unable to create new native thread
I tried to clean and build again. I tried to change studio.vmoptions but none of them worked for me.
Here is the full build.gradle file:
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Pls update distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip in gradle-wrapper.properties file at gradle folder then rebuild your project.

Could not find method android() for arguments in Android Studio project [duplicate]

This question already has answers here:
Could not find method android() for arguments
(4 answers)
Closed last month.
I am trying to do a grade sync on my android studio project and I keep getting this error in the title. My build.gradle file 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:2.2.1'
// 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 24
buildToolsVersion '24.0.0'
}
dependencies {
}
My error message is
Gradle sync failed: Could not find method android() for arguments [build_aiwlctiq29euo9devcma4v4r7$_run_closure3#22efc0bc] on root project 'MyRadio
I have looked online and tried multiple solutions but nothing seems to work. What does this even mean? Any help would be appreciated.
Move your android{} part to this file
currently you are editing top level gradle file but you have to edit App level
add dependencies over there.
Each module you add in your Android Studio Project has its own build.gradle file. Any dependencies that you want to add is added in associated module build.gradle file.
So in your case you have to add your dependencies in your app's build.gradle file.
Here is an image showing where you should add that.
Refresh gradle after deleting the below
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
}
dependencies {
}
It works for me
Check if your APP Level Build.Gradle is missing Plugin
then Add apply plugin: 'com.android.application'
in APP Level Build.Gradle
From My solution.

Gradle DSL method not found android()

I open a friend project at Android Studio, my AS version is greater than his.
Here is the error:
Error:(27, 0) Gradle DSL method not found: 'android()'
Possible causes:The project 'firstapp' 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.
Here is the 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:2.2.0-alpha1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 19
buildToolsVersion '21.0.0'
}
dependencies {
}
How can i get this fixed?
Look here from official doc.
https://developer.android.com/studio/build/index.html
/**
 * The first line in the build configuration applies the Android plugin for
 * Gradle to this build and makes the android {} block available to specify
 * Android-specific build options.
 */
apply plugin: 'com.android.application'

Exception : mergeDebugResources in Android Studio

I got following Error if I try to add dependency in Top - level build.gradle file. This dependency is very much useful to add GCM in project without it GCM won't work:
Dependency :
classpath 'com.google.gms:google-services:1.5.0-beta2'
Error :-
Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details
If I remove that dependency from top-level build.gradle the project compiles and run successfully.
If I add that file I got the error and Android Studio do not run project.
Please help me to get out of this error.
Edit
Here is my project level build.gradle file:-
// 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.0.0-alpha6'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
// 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
}
try Changing latest version of dependency from HERE:
classpath 'com.google.gms:google-services:2.0.0-beta5'
Also make sure you are setting correct Gradle plugin dependency as well in root project gradle file.
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
So, your final project build.gradle file will look like
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
}
Try this it should help.
buildTypes {
release {
multiDexEnabled true;
}
}
in your Gradle log, if you're getting bad/invalid PNG file then take a look at my answer at Android Studio Gradle 2.0.0-alpha1 build errors
Hope this helps...

Categories

Resources