I'm not able to setup Android Data Binding - android

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
}
`

Related

Unsupported method: BaseConfig.getApplicationIdSuffix(). somehting missed in my build.gradle file

i know the problem is stated at : Unsupported method: BaseConfig.getApplicationIdSuffix(), but the thing is that i don't have 'classpath' in builde.gradle file at all to change it. here is the build.gradle content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
android studio 4.0.
i am new to android,
any help is highly appreciated
In your project's build.gradle file add this
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
}

Error(3,0) Gradle DSL method not found: 'buildToolsVersion()'

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'
}

Cannot Update buildtool version from build.gradle

I was trying to update build tool version from build.gradle and got this Gradle Sync Error message
:- I juset went to build.gradle file inside the app directory and changed the:
buildToolsVersion '20.0.1' to buildToolsVersion '23.0.0' and then everything went wrong.
so I looked at the SDK manager but the build tool is installed there
What should I do now?
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.didyoufeelit"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
repositories {
mavenLocal()
mavenCentral()
google()
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
}
try to update this into the build.gradle

Unable to use amlcurran.showcaseview library in android studio

I am trying to use amlcurran/showcaseview library and i am following this tutorial, but i am unable tor resolve the library:
Error:(29, 13) Failed to resolve: com.github.amlcurran.showcaseview:library:5.0.0
Here is my build.gradle(project) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wolverine.showcasetutorial"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "http://jcenter.bintray.com" }
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
}
Please help me to fix this.
add this your manifest file
<uses-sdk tools:overrideLibrary="com.github.amlcurran.showcaseview"/>

Add external library into android studio 0.5.1 project

I'm using an external library SVProgressHUD in my Android studio project as a module. Everything is fine until I upgraded my Android studio to 0.5.1. It always shows the follow error message:
Error:(7, 17) package org.lcsky does not exist
Here is my settings.gradle:
include ':app',':SVProgressHUD'
My build.gradle in project folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
My build.gradle in SVProgressHUD module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
The build.gradle in my main module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SVProgressHUD')
}
The gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
Can anybody tell me what could be wrong? Thanks
I solved the problem by changing the build.gradle in SVProgressHUD module:
apply plugin: 'android-library'
Previously it works (before Android 0.5.1) when I set it to:
apply plugin: 'android'

Categories

Resources