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

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.

Related

Cannot resolve class androidx.drawerlayout.widget.DrawerLayout or com.google.android.material.navigation.navigationview

I have an app that works properly. Anyway, I have a "strange" behaviour of Android studio, in fact for the xml files it is not able to solve some classes, i.e. drawerLayout, constraintLayout, CircleImage etc. (see the image below)
Before opening android studio I have a warning about adding project dependencies:
Problem: Inconsistencies in the existing project dependencies found.
Version incompatibility between:
androidx.navigation:navigation-ui:2.5.1#aar and:
androidx.appcompat:appcompat:1.5.0#aar
With the dependency:
androidx.annotation:*1.1.0
androidx.annotation:*.2.0.0
What I tried:
invalidating caches and restarting app
update my gradle file, as shown below:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'androidx.navigation.safeargs'
}
apply plugin: "androidx.navigation.safeargs"
sourceSets {
main {
java {
}
}
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.frangela"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation "androidx.navigation:navigation-fragment:2.5.1"
implementation "androidx.navigation:navigation-ui:2.5.1"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-database:20.0.5'
implementation 'com.google.firebase:firebase-common-ktx:20.1.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.9.1'
implementation platform('com.google.firebase:firebase-bom:30.3.1')
implementation 'com.google.firebase:firebase-functions'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.firebaseui:firebase-ui-database:8.0.1'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation 'com.squareup.picasso:picasso:2.8'
implementation 'com.google.firebase:firebase-messaging'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
}
My gradle Module:
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://repo1.maven.org/maven2' }
}
dependencies {
def nav_version = "2.5.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.13'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I think that there could be problems with the dependencies, but for example I cannot find any of that regarding annotation in my gradle file.
Thank you in advance for anyone that could help me.
You're applying androidx.navigation.safeargs twice and srcDirs += 'build/generated/source/navigation-args' also is useless. With high probability, this project is lacking a proper repositories configuration, while the question complete ignores this part. In case there should be any jcenter() repository, replace that with mavenCentral() or google().
After hours of works, I solved in a pretty easy way:
Copy all the project in another location on my PC
Reopen the project
After opening it from Android Studio, everything works fine

Error in gradle when implement hilt library in android

I am trying to implement hilt in android studio version 2020.1.1 Canary 1 but I get this error in gradle
Unable to find method ''void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTests$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)''
'void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTests$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)'
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.
Here's the build.gradle level project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.0.0-beta07'
kotlin_version = "1.4.32"
lifecycle_version = "2.3.1"
hilt_version = '2.35'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and build.gradle level module
plugins {
id 'com.android.application'
id 'kotlin-android'
id("kotlin-kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
}
android {
compileSdk 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.android.gymexercisestracker"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
dataBinding true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.32'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
//Android Room
implementation "androidx.room:room-runtime:2.4.0-alpha02"
implementation "androidx.room:room-ktx:2.4.0-alpha02"
kapt "androidx.room:room-compiler:2.4.0-alpha02"
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-android-compiler:$hilt_version")
}
and gradle-wrapper.properties
#Wed May 26 14:56:53 EET 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
I tried to Clear cache and restart but same problem
I had the same issue the answer from GitHub fixed it for me. link
dagger github
Edit your project level build.gradle
Before
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath ClassPaths.gradlePlugin
classpath ClassPaths.kotlinPlugin
classpath Libs.Hilt.gradlePlugin
classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
}
}
After
buildscript {
repositories {
google()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
content {
includeModule("com.google.dagger", "hilt-android-gradle-plugin")
}
}
}
dependencies {
classpath ClassPaths.gradlePlugin
classpath ClassPaths.kotlinPlugin
classpath "com.google.dagger:hilt-android-gradle-plugin:HEAD-SNAPSHOT"
classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
}
}
This is weird issue even i faced, i solved it by making sure
these 2 dependencies version in Build.gradle(app) matches, hopefully this helps you as well
implementation "com.google.dagger:hilt-android:2.31-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.31-alpha"
Here is my full dependency list for hilt
Build.gradle(app)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
dependencies {
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.31-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.31-alpha"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt "androidx.hilt:hilt-compiler:1.0.0"
}
build.gradle(project)
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha"
}

Android Studio 3.6.1 with Gradle Plugin Version 3.6.1 and Gradle Version 5.6.4 not working

My application is working very well. I have just updated Android Studio 3.6.1,
After updating Android Studio I got this dialog and I am going to update the version of the Gradle Plugin as below.
After updating, My application getting crashed and getting the following errors.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/R$string;
at com.google.android.gms.common.internal.StringResourceValueReader.<init>(Unknown Source:4)
at com.google.firebase.FirebaseOptions.fromResource(com.google.firebase:firebase-common##19.3.0:156)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common##19.3.0:244)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common##19.3.0:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1940)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1915)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common##19.3.0:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:6770)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6317)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6232)
at android.app.ActivityThread.access$1200(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1792)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7078)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
My Project Level build.gradle is:
buildscript {
ext.objectboxVersion = '2.5.0'
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Add dependency
classpath 'io.fabric.tools:gradle:1.31.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and My App Level build.gradle is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: "androidx.navigation.safeargs"
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.sohamerp.marsremedies"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
dataBinding {
enabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
//implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
annotationProcessor 'androidx.annotation:annotation:1.1.0'
implementation "com.github.firdausmaulan:GlideSlider:1.5.1"
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'org.greenrobot:eventbus:3.1.1'
debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"
implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
// apply the plugin after the dependencies block
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.objectbox'
There is only one solution which I have tried is reverting back the version of Gradle
which I have updated but what if I want to use the latest versions.
Update:
One of my projects is working with some version of Android Studio
and Gradle. Here is Firebase SDK is different in both project so I
am thinking that Firebase is Project.
Any help? What should I do?
I have tried many ways to solve this problem as follow:
1st solution: I have tried the solution of Mayur Sojitra and it worked for one day. (Next day I got the same problem again.)
2nd solution: I have tried to revert back with a lower version of Gradle that is 3.5.0 and It's working but I wanted to use the latest version only. (Way to find a new solution)
3rd solution: I am using firebase dependencies and I thought that error is coming because of Firebase version conflicts with Gradle so I have updated all the firebase repository. (May this is also working for you)
4th solution: I have used ObjectBox library so updated that version to the latest 2.5.1.
5th solution: Finally I caught the problem that My Internet Connection is restricted (as per company rules) and My Gradle and other dependencies are not downloading successfully so I thought updating all dependencies and download it successfully will be the solution for this weird question.
Do let me know If you have any questions or still get a problem.
Thank you.
buildToolsVersion "29.0.2"
remove this line from build.gradle
It seems like you're mixing old fabric&crashlytics with new firebase&crashlytics. Try:
Project Level build.gradle:
buildscript {
ext.objectboxVersion = '2.5.0'
repositories {
google()
jcenter()
// maven {
// url 'https://maven.fabric.io/public'
// }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Add dependency
// classpath 'io.fabric.tools:gradle:1.31.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Level build.gradle:
apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"
//apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
// buildToolsVersion "29.0.2" // buildtools is now automatically determined, based on compileSDKVersion
defaultConfig {
applicationId "com.sohamerp.marsremedies"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
dataBinding {
enabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
//implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
// implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
annotationProcessor 'androidx.annotation:annotation:1.1.0'
implementation "com.github.firdausmaulan:GlideSlider:1.5.1"
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'org.greenrobot:eventbus:3.1.1'
debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"
implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
// apply the plugin after the dependencies block
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.objectbox'
If you're still looking at this, I just got an update to 3.6.2 and it specifically did some firebase-related update (although my code doesn't use firebase..) immediately after restart.
I ran into the same error. However, I succeeded in building in the following way.
- classpath 'com.google.firebase:firebase-plugins:1.1.1'
+ classpath 'com.google.firebase:firebase-plugins:1.2.0'
Possible solution:
Upgrade the version of plugins in Top-level build.gradle.
Detail:
I upgraded the Gradle version from 5.4.1 to 5.6.4, and the plugin version from 3.5.3 to 3.6.2, and then I encountered a problem that the class could not find.
I have used Realm in the project and the top-level build.gradle is:
// 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.6.2'
classpath "io.realm:realm-gradle-plugin:5.8.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
This problem seems like some library/plugin does not process R classes in R.jar but in R.java after the Gradle plugin version greater than 3.6.0. See here for detail.
And the solution is to upgrade Realm to a newer version, for me is 6.0.2. See here for detail.
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "io.realm:realm-gradle-plugin:6.0.2" // <- modify
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
gradle 5.6.4 having some sync problem . go to the gradle-wrapper.properties and change the url
to this
distributionUrl=https://services.gradle.org/distributions/gradle-6.0-all.zip
I tried many suggestions from stackoverflow(here), github forums etc.
Checked gradle and gradle plugin versions if there is any compatibility problems.
Only worked :
I clean .idea and .gradle file, exit AndroidS, and I open my react native proj on Android studio and I did open from file choose android folder, after that waited android studio finish indexing(really waited this time) and press hammer icon for build and wait again patiently and build-run on simulator successfully.
I didn't wait before, I guess I didn't imagine that Android studio takes so much time to index-run-build
I am sharing if somebody still stuck, key was waiting for me, good luck

Unresolved dependencies in Android Studio project

Issue: I've recently updated/installed the latest version of Android Studio and I imported a little old project. When I sync the project I get these errors:
The errors are as follows:
Failed to resolve: com.google.android.gms:play-services-ads-identifier:12.0.1
Show in Project Structure dialog
Affected Modules: app
Failed to resolve: com.google.firebase:firebase-measurement-connector:12.0.1
Show in Project Structure dialog
Affected Modules: app
I tried to add all the necessary elements to the gradle and I tried installing Google Play Services in SDK. My project is imported from the Desktop.
This is my app/build.gradle:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.0'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.albetaqasite"
manifestPlaceholders = [
onesignal_app_id : 'cc95bb51-0699-4309-9322-be8793d5e564',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE']
minSdkVersion 15
targetSdkVersion 29
versionCode 55
versionName "3.4.1"
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
}
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
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/android-async-http-1.4.4.jar')
implementation project(':ColorDialog')
implementation files('libs/universal-image-loader-1.9.4.jar')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
//implementation 'cn.pedant.sweetalert:library:1.3'
implementation 'com.github.f0ris.sweetalert:library:1.5.1'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.google.android.gms:play-services:8.4.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.+'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.+'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
implementation 'com.google.android.gms:play-services-identity:8.4.0'
//compile 'com.google.android.gms:play-services-gcm:8.4.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
// compile 'com.google.firebase:firebase-core:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
This is my Project/build.gradle:
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://maven.google.com" // Google's Maven repository
} }
}
dependencies {
}
P.S: I'm aware of the problem in android.com.support dependencies, when I change the compileSdkVersion and targetSdkVersion to 27 it works, but the gradle ones I couldn't fix, kindly share your knowledge and experience if you've ever encountered this or have any idea how to solve it.
I think you need to add entries for those dependencies down in the section near these entries:
implementation 'com.google.android.gms:play-services:8.4.0'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
implementation 'com.google.android.gms:play-services-identity:8.4.0'
However, if you try to bring in version 12.0.1 of one library, and version 8.4.0 of another related library, you are probably going to have issues. See if you can bump up the version number of these three to 12.0.1

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