Please I am a beginner in Android development.
I just tried to run my first code in line with the tutorial I am using to learn.
I got this error:
Gradle DSL method not found: 'buildToolsVersion()'
This is my build.gradle(Project:HappyBirthday)
// 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.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
}
And this is my build.gradle(Module:app)
apply plugin: 'com.android.application'
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 15
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.4.0'
}
You seem to be missing the android closure and your compileSdkVersion line. Change your second file to look like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 15
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.4.0'
}
Related
In a week, I struggled with some errors on Android Studio.
I want add Zxing Library dependencies in my project. But everytime I add the dependencies. I got this error
"Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve..."
I did remove "compile" with "implementation" on every dependencies that I'm looking for.
FYI: I've succeeded add Volley Library. No error appear.
This is my TOP build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my APP build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "id.plevia.projectx.app"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature')
implementation project(':base')
implementation('com.android.volley:volley:1.1.1')
}
This is my BASE build.gradle
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
baseFeature true
defaultConfig {
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api 'com.android.support:appcompat-v7:28.0.0-rc02'
api 'com.android.support.constraint:constraint-layout:1.1.3'
application project(':app')
feature project(':feature')
implementation('com.android.volley:volley:1.1.1')
}
This is my FEATURE build.gradle
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':base')
implementation('com.android.volley:volley:1.1.1')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
All the build.gradle script above without Zxing dependency.
All I want to do is to make Barcode Scanner without pressing a button on every scan
Thank you.
As #Arbaz.in answer in comment section. The answer of my problems is
Uncheck Offline work option
File->Other Settings->Default Settings->Build, Execution, Deployment->Build Tools->Gradle->Uncheck Offline work option
I have this in my root build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
and in the app build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.company.app"
minSdkVersion 14
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
//more third-party libraries
}
And this is my layout:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="user"
type="com.company.app.models.LoginCredentials"/>
</data>
<EditText
android:layout_width="match_parent"
android:layout_height="55dp"
android:text="#{user.username}"/>
<!-- More layouts and widgets -->
</layout>
But I get this error:
Error:(82, 35) No resource type specified (at 'text' with value
'#{user.username}').
I have tried to put:
dataBinding {
enabled = true
}
but I get this another error:
Error:Could not find com.android.databinding:library:1.0-rc3.
How can I do? I have just updated Android Studio to v1.5.1.
Actually compileSdkVersion 21 creating problem . You need to use UPGRADED Version .
You should use
compileSdkVersion 23
buildToolsVersion "23.0.1"
&
targetSdkVersion 23
You need to include dataBinding.enabled = true
Add classpath "com.android.databinding:dataBinder:1.0-rc1" to your build.gradle like this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
}
Change your build.gradle on putting what as mentioned in the previous comments of #IntelliJAmiya and adding apply plugin: 'com.android.databinding' Your gradle will be like
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.company.app"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dataBinding {
enabled = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
//more third-party libraries
}
`
I have an Android project built using gradle 1.10. I would like to build it using gradle 2.4. There are few threads where some changes are suggested which should do the job. Some users have said these changes have worked and some have not worked.
I would like to know if there is a way I can copy certain number of files and build the whole thing from scratch using Gradle 2.4?
Thanks.
It was built using Android Studio 0.5.1.
Here is Project level build.gradel:
// 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:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Here is the module level build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Using the current Android Studio 1.3 you should use this top-level build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
The module/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion XX
buildToolsVersion "XX.X.X"
defaultConfig {
minSdkVersion 14
targetSdkVersion XX
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:XX.X.X'
compile 'com.android.support:support-v4:XX.X.X'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Pay attention to use gradle 2.4 and change the gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
I'm trying to reference SpotifyWebApi in AndroidStudio. I'm using the instructions here
https://github.com/kaaes/spotify-web-api-android/blob/master/README.md
However I get the error
Error:Failed to resolve: :spotify-web-api-android-0.1.0:
when I try to build.
How can I fix this? I have AndroidStudio 1.2.2
Here's my Module:app build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "app.com.example.android.spotifystreamerstage1"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'spotify-web-api-android-0.1.0', ext:'aar')
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
// Other dependencies your app might use
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
spotify-web-api-android is not included maven central repository. the doc of the link has wrong info. I don't know why..
Alternatively I have found this link and next codes.
repositories {
maven {
url "https://github.com/z0lope0z/raws/raw/master"
}
mavenCentral()
}
dependencies {
compile 'kaaes.spotify.webapi.android:spotify-web-api-android:0.1.0'
}
I get this error during gradle build when importing a project in android studio o.8.14
Gradle DSL method not found: 'android()''
I know the error has something to do with the gradle files but I don't know the way forward or where exactly to start.
The top level build.gradle file looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
}
And the module build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.shimba.android.events"
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile project(':universalImageLoaderLibrary2')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:20.+'
}
Where am I going wrong?