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'
Related
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.
I have been many issues with the new Android Studio release (3.2.1) when I try to build the project.
I'm working with android-sunflower (jetpack integration) project and I'm getting the following error.
Is someone else getting this error?
Plugin [id: 'com.diffplug.gradle.spotless', version: '3.13.0'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:3.13.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Open File
Adapt this for your top level build.gradle file for your project . Add plugins and spotless.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.4.0"
}
allprojects {
repositories {
jcenter()
}
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
}
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
target "**/*.java"
trimTrailingWhitespace()
removeUnusedImports()
googleJavaFormat()
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Spotless documentary say this for using it:
To use it in your buildscript, just add the Spotless dependency, and
configure it like so:
spotless {
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
format 'cpp', {
target '**/*.hpp', '**/*.cpp'
replace 'Not enough space after if', 'if(', 'if ('
replaceRegex 'Too much space after if', 'if +\\(', 'if ('
// Everything before the first #include or #pragma will
// be replaced with whatever is in `spotless.license.cpp`
licenseHeaderFile 'spotless.license.cpp', '#'
}
}
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.
My project at run time, there was a gradle version of the error, I tried a lot of ways are not resolved, we have not encountered a similar error, the following is the error log.
Error:(1, 0) Gradle DSL method not found: 'apply()' Possible
causes:The project 'xindatx1.6.0' 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). Fix plugin version and sync
projectThe project 'xindatx1.6.0' 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i have searched and tried all stackover flow methods its not helping.
i get this
// 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.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
when i try add (22 lolipop ) & 23.0.1 it shows open gradle wrapper file & apply plugin nothing works
Error:(19, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'booook' 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>
// 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.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 22
buildToolsVersion '23.0.1'
}
dependencies {
}
thats what i get in end results after making changes
http://s9.postimg.org/fzg0sie8v/image.png
http://s30.postimg.org/6eepfqxtd/image.png
http://s11.postimg.org/b6l12ec8z/image.png
http://s11.postimg.org/b6l12ec8z/image.png
You are in the top level build file (first line of the file)
You should add this new content in your sub-project (usually app/build.gradle)
Remove these lines from your top-level build.gradle
android {
compileSdkVersion 22
buildToolsVersion '23.0.1'
}
dependencies {
}
It is the reason of
Error:(19, 0) Gradle DSL method not found: 'android()'