Build and Run an old Android Project in Android Studio - android

I am given the zipped project source code of an Android project integrated to AWS services. I need to understand and be able to add some new functionalities to the app but I cannot successfully run the project in android studio. I am using Android Studio 4.1.3.
I am new to Android and AWS and I am just learning these technologies.
How and where should I start studying the code?
Also if you could help me solve the issue I am encountering in Android Studio.
I already tried killing all gradle daemons and killing all java processes but I still encounter the same issue.
Android Studio Issue
Unable to find method 'org.gradle.api.internal.file.DefaultSourceDirectorySet.(Ljava/lang/String;Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;Lorg/gradle/api/internal/file/collections/DirectoryFileTreeFactory;)V'
org.gradle.api.internal.file.DefaultSourceDirectorySet.(Ljava/lang/String;Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;Lorg/gradle/api/internal/file/collections/DirectoryFileTreeFactory;)V
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
below is the build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.amazonaws:aws-android-sdk-appsync-gradle-plugin:2.9.+'
}}
allprojects {
repositories {
google()
jcenter() }}
task clean(type: Delete) {delete rootProject.buildDir}
below is the build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.amazonaws.appsync'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.dostcandle.ecrf"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}}
dependencies {
def lifecycle_version = "2.0.0"
def room_version = "2.2.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.fragment:fragment-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.amazonaws:aws-android-sdk-core:2.15.+'
kapt "androidx.room:room-compiler:$room_version"
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.jaredrummler:material-spinner:1.3.1'
implementation 'ph.ingenuity.tableview:tableview:0.1.0-alpha'
implementation 'com.amazonaws:aws-android-sdk-appsync:2.8.+'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.15.+'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.15.+'
implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.15.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'}

You're using an old version of the AppSync SDK that is not compatible with Android Gradle Plugin 4.x / Gradle 6+. Right now, I see that you're using AGP 4.x.
See this GitHub issue for more details.
You have two options:
Use older versions of Gradle & Android Gradle Plugin. Specifically, 3.6.3 of the plugin, and 5.6.4 of Gradle.
Update your AppSync dependencies to at least 3.1+. See the setup notes in the project's README for more details.
Source: I authored the fix for this issue in the AppSync SDK.

apply these:
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'com.amazonaws.appsync'
instead of these:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.amazonaws.appsync'
if still it does not work then simple add these:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

Create new project most of the code should be obsolete. If you want to run existing code change jcenter() to mavenCentral() also check aws documentationhttps://aws.amazon.com/getting-started/hands-on/build-android-app-amplify/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.32"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Add this line into `dependencies` in `buildscript`
classpath 'com.amplifyframework:amplify-tools-gradle-plugin:1.0.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'com.android.application'
id 'kotlin-android'
}
apply plugin: 'kotlin-kapt'
apply plugin: 'com.amplifyframework.amplifytools'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.dostcandle.ecrf"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.amplifyframework:aws-api:1.17.3'
implementation 'com.amplifyframework:aws-datastore:1.17.3'
implementation 'com.jaredrummler:material-spinner:1.3.1'
implementation 'ph.ingenuity.tableview:tableview:0.1.0-alpha'
implementation 'com.amazonaws:aws-android-sdk-appsync:2.8.+'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.22.6'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.22.6'
implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.22.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

Related

android studio error java.lang.NullPointerException: Cannot get property 'kotlin_version' on null object when i try to build

i just learnt kotlin and im trying to put my skills to practice, i created a new project and even implemented firebase authentication, now i try to creaate a new activity and im getting
java.lang.NullPointerException: Cannot get property 'kotlin_version' on null object
Error on build console. i have tried to get similar questions though none was very directly related to mine.
This is how my top level gradle file looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:perf-plugin:1.3.1'
// 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 level gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.findmyapartment"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 kotlin_version
targetCompatibility JavaVersion.VERSION_1_8 kotlin_version
}
kotlinOptions {
jvmTarget = "1.8"
}
viewBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7: $kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-auth-ktx:19.3.2'
implementation 'com.google.firebase:firebase-firestore-ktx:21.5.0'
implementation 'com.google.firebase:firebase-storage-ktx:19.1.1'
implementation 'com.google.firebase:firebase-perf:19.0.6'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.5'
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha04"
debugImplementation "androidx.fragment:fragment-testing:1.3.0-alpha04"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
with that i'm convinced my kotlin configuration is done fine by android studio itself and
i havent added any updates or pluggins. i will appreciate if somebody helps me.

amplify-gradle-config.json (The system cannot find the file specified)

i was trying to use AWS amplify facilities with my android app. my gradle is failed to build with an error showing.
this is my app gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
compileSdkVersion 29
defaultConfig {
applicationId "com.example.azuretest"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0-alpha02'
implementation 'com.amplifyframework:core:0.9.0'
implementation 'com.amplifyframework:aws-api:0.9.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
this is my project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.60'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.amplifyframework:amplify-tools-gradle-plugin:0.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.amplifyframework.amplifytools'
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is the error:
F:\AzureTest\amplify-gradle-config.json (The system cannot find the file specified)
Note: I'm totally new on this platform, I'm sorry if I violate the protocols of asking question.
You must have missed a step while you were following creating the app. Refer to Step 3. in the following document:
https://aws-amplify.github.io/docs/android/start
For part a. regarding amplify configure, make sure to run that in your app's root directory. (in your case F:\AzureTest)
Make sure to perform part b. in your Android Studio toolbar as well

Android studio: Kotlin scope functions Unresolved reference. But Project compiles

I am facing this strange issue where my project compiles and runs successfully but in my kotlin scope functions red errors are coming. It also shows errors on some of the kotlin functions like toLong(), toDouble() etc.
and I have this in my gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.xyz"
minSdkVersion 19
targetSdkVersion 28
versionCode 4
multiDexEnabled true
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
def lifecycle_version = "2.0.0"
def room_version = "beta01"
implementation fileTree(dir: 'libs', include: ['*.jar'])
//android X
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
implementation 'com.android.support:multidex:1.0.3'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
api 'de.hdodenhof:circleimageview:3.0.0'
api 'com.jakewharton:butterknife:10.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
// For Kotlin use kapt instead of annotationProcessor
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.20'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "androidx.room:room-runtime:2.2.0-$room_version"
implementation "androidx.room:room-ktx:2.2.0-$room_version"
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
api(name: 'sdk-release-1.6.1', ext: 'aar') {
transitive = true
}
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
//annotation processors
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
annotationProcessor "androidx.room:room-compiler:2.2.0-$room_version"
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
//facebook app events sdk
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Gradle Properties
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
build gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
classpath 'com.google.gms:google-services:4.3.1'
classpath 'io.fabric.tools:gradle:1.31.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried Invalidate cache/Restart and also tried deleting .idea and .gradle files nothing helped, I have also tried to restart the android studio and also tried to change branches from git nothing helped.
any help appreciated.
I had similar experience on Android Studio with Kotlin since 2 weeks ago.
When I import a project on GitHub with old Kotlin plugin version 1.3.31. I quickly changed it to 1.3.72 (the latest kotlin) then, I had had this error too.
I could fix the error when I changed the plugin version to 1.3.61 (older version) and sync my project. It removed the error and update it to the latest plugin version 1.3.72. And everything worked smoothly now.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha06"
}
}
I was like magic.
Just changed the Kotlin plugin version to a 2 or 3 older versions backward and sync your project. I should work
I hoped it helps
Change this line
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50'
Into
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50'
And then do again, clean build then invalidate cache and restart.

firebase-measurement-connector-impl cannot be resolved when syncing with gradle files

In short, when I implement the latest version of firebase-core (version 16.0.7) in my APP-LEVEL build.gradle file, and when I sync with Gradle files, it fails to download one of the dependencies for firebase-core, called firebase-measurement-connector-impl. It searches for version 17.0.5, and it fails to download it.
I took a look at Google's Maven repository (maven.google.com) and in mvnrepository.com, and the version exists. But when I try to download the .jar file manually myself (using Chrome), it ALSO errors out! It says "Error - no file". Am I onto something, or am I missing something (like always)?
App-level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
check.dependsOn 'assembleDebugAndroidTest'
android {
compileSdkVersion 28
flavorDimensions "minSdkVersion"
defaultConfig {
applicationId "me.testweb.firebaseoauthtest"
buildToolsVersion("28.0.3")
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
buildToolsVersion '28.0.3'
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-
annotations:28.0.0'
}
dependencies {
implementation project(':chooser')
implementation project(':lintchecks')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// Firebase Authentication
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-auth:16.1.0'
// Google Sign In SDK (only required for Google Sign In)
implementation 'com.google.android.gms:play-services-auth:16.0.1'
// Firebase UI
// Used in FirebaseUIActivity.
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
// Twitter Android SDK (only required for Twitter Login)
implementation 'com.twitter.sdk.android:twitter-core:3.3.0'
implementation 'com.twitter.sdk.android:twitter:3.3.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.21"
}
apply plugin: 'com.google.gms.google-services'
Project-level 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.3.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
}
}
allprojects {
repositories {
//mavenLocal() must be listed at the top to facilitate testing
mavenLocal()
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The expected result, is that the build process will download everything successfully (including firebase-measurement-connector-impl), and it won't show any errors.
The actual result, is that it will FAIL to download firebase-measurement-connector-impl, but everything still builds successfully (???).
Change from
implementation 'com.google.firebase:firebase-core:16.0.7'
To
implementation 'com.google.firebase:firebase-core:16.0.5'

Issue with data binding with gradle 3.2.1

When i have updated android studios 3.2.0 to 3.2.1. I have use data binding, when run project show me error like this, if i am wrong please suggest me.
Could not find com.android.databinding:compiler:3.2.1.
Searched in the following locations:
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
Required by:
project :app
project.gradle
buildscript {
ext{
kotlin_version = '1.2.71'
gradle_version = '3.2.1'
}
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
dependencies {
classpath "com.android.tools.build:gradle:3.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.taufik.kotlinbindingtest"
minSdkVersion 19
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'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
kapt "com.android.databinding:compiler:$gradle_version"
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'
}
If i am wrong please suggest me.
I looked for many solution and finally i found that problem was in one of Dependencies, So I removed this kapt "com.android.databinding:compiler:$gradle_version" from app.gradle and project run succeffully.
The answer is pretty simple:
just add these lines in gradle app
//Data binding
dataBinding.enabled = true
and remove these two lines :
apply plugin: 'kotlin-kapt'
kapt "com.android.databinding:compiler:$gradle_version"
As of Android Studio 3.2, this kapt plugin is no longer required.
However, without this plug in, the error message in case of any error, while compiling is cryptic.
So, only option now it seems now is to downgrade your Gradle version to 3.1.4.
Thanks to article at http://mobiledevhub.com/2018/01/05/android-two-way-databinding/

Categories

Resources