Gradle: DSL method not found: minSdkVersion / targetSdkVersion / compileSdkVersion / buildToolsVersion - android

As it took me some time to find the solution for this error, I post my problem and solution here in the hope that I find it next time faster:
Error:(39, 0) Gradle DSL method not found: 'minSdkVersion()'
What I tried to do:
I followed the Android Test Blueprint's sample to define the library versions in the top level / rootProject'S build.gradle file:
ext {
minSdkVersion 16
}
And wanted to use it in the app's/module's build.gradle file:
minSdkVersion rootProject.ext.minSdkVersion

After half an hour or so I notices that this was a simple typo -.-
Solution
Add the "=" sign when you define a variable, else, Gradle thinks you call an Android method which it does not yet know in the top level build file:
ext { minSdkVersion = 16 }

Related

AndroidStudio Failed to Sync Gradle project, Failed to find target Google Inc

How can I resolve the Gradle Sync problem?
I installed the missing SDK versions but the error shown again.
Take a look to the screenshots please...
Screenshot 1
Screenshot 2
Thank you in advance.
Your compileSdkVersion must be a number, not a String
Example:
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.yourpackage.yourapp"
minSdkVersion 11
targetSdkVersion 24
versionCode 4
versionName "1.3"
}
...
}
You also need to open up "build.gradle" script and change the classpath to latest gradle repository.... mine is 'com.android.tools.build:gradle:3.0.0-alpha3'
Hope this helps everyone

I will try to change the version code and version name for android app but it gives the following error

C:\Users\hp-\IdeaProjects\new\app\build.gradle
Error:(11, 0) Gradle DSL method not found: 'versionCode()'
Possible causes:<ul><li>The project 'new' 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>
This was the error how to fix it?
I will change in build.gradle as follows
defaultConfig {
applicationId " name.name"
minSdkVersion 15
targetSdkVersion 24
versionCode 1.1
versionName "1.1"
}
you cant use a float number for versionCode. you must use an integer number.
just versionCode must be more than previous versionCode like it:
1, 2, 3, 4, ...

Phonegap Build Error with multidex dependency

I'm trying to export my apk but I'm receiving one build error below:
I've added compile 'com.android.support:multidex:1.0.1' in my build.gradle dependencies, enabled multidex in my defaultConfig and also added android:name="android.support.multidex.MultiDexApplication"> within my Android Manifest file but am still receiving the error.
===============================
My build.gradle can be found here:
http://pastie.org/10902207
================================
What is going on? Can anyone give me some insight as to why I am receiving this?
I imagine the issue you are having is because you do not have a minSDK defined in your Build.gradle. The library you are trying to uses minSDKVersion 4.
If you don't specify your minSDKVersion your project is going to automatically default to version 1. Try adding something like the below to your build.gradle file.
android{
compiledSdkVersion 23 //marshmallow
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 11 //honeycomb
targetSdkVersion 23
}
}

Getting issue while importing (Mateial Design calendar) library module in android studio

I am getting this error ,how to fix it.
Error:(12, 0) Cannot get property 'versionCodeInt' on extra properties extension as it does not exist
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode project.ext.versionCodeInt -> getting error this line
versionName version
}
Error:(12, 0) Cannot get property 'versionCodeInt' on extra properties
extension as it does not exist
This error means that variable versionCodeInt which you are trying to use in build.gradle of Module level is not properly set up in build.gradle file of Project's root level.
So, please check if root build.gradle contains such code:
project.ext {
versionCodeInt = 2 // actually here should be your current version code
}
try this, it's working for me
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}

Android compile project with target="android-19" failed

Masters,
Recently I am trying to build android project with gradle, and since there one API(#JavascriptInterface annotation) I need to use is only up to api level 17, so I changed my targetAPILevel to 19 in project properties. And it works well when I build the project from Eclipse(Right click on project and Run Android Application).
But when I tried to build the project by gradlew in terminal, it seems it never use target level 19 to build the project. Here is part of the build.gradle file as follow:
android {
// target = 'android-19'
compileSdkVersion 19
buildToolsVersion '19.0.1'
}
Can anyone help me what I did wrong in here, please? Thank you very much.
TargetSdkVersion and compileSdkVersion are different parameters.
In eclipse, you set the target in your Manifest, and set the api used to compile with right click -> properties -> Android Manu.
In your build.gradle you should use something like this:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}

Categories

Resources