can't not build my app due to an appcompat error - android

I just got the android studio and all I did was connecting with the firebase. But I was not able to fully connect because of the appcompat error. I have attached the photo of what I'm getting.
dependencies {
implementation fileTree(dir: 'libs',include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0' <--------------getting error here
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:11.6.0'
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'
}
Error
Dependencies

I look at your error message and it felt familiar as i had received same message so many times!
Root cause is mixing version numbers in dependencies. it seems that in your dependencies you have version 28 and version 25 mixed up. go to build.gradle and put cursor on version number on each of your dependancies and then press ALT+ENTER. go with what android studio suggests and then clean->rebuild. it should work.
Hope this helps!

Related

commenting gradle dependencies

I have built an application in Android Studio 4.0.1. The dependencies in my gradle script have all been auto-generated, and I am not sure if they are needed. When I run the app into my phone, it shows a size of 7MB. If I comment the dependencies of the gradle script, the size of the app goes down to 3 MB, and it seems to work the same. Can I just comment those dependencies?
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Yes it is absolutely possible (and you're good to go) if you want to remove UNUSED dependencies. If you end up removing any dependency that you are currently using in your app you will not be able to run your app as it will throw compile error because the compiler won't understand any code that is based on the dependency(s) that you just removed.
For example if you remove the dependency for constraint layout and you have used constraint layout in your project your app won't be compiled. You can google search about any particular dependency to decide whether or not you have used certain dependency on your project.
As you asked in the comments the following dependencies are used for testing your app, if you are not testing your apps you can remove them as well.
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

android package dependency download via api command

I am really new to android dev (C/Python engineer), and I am looking to include a package from github where it says download the package using:
api 'com.otaliastudios:cameraview:2.0.0-beta04'
I have spent 2 hours looking WTF this api tool is but for the life of me, I cannot seem to figure out what it is.
My dependency block looks like so:
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.constraint:constraint-layout:1.1.3'
implementation 'com.otaliastudios:cameraview:2.0.0-beta04'
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'
}
As you see, I have added the:
implementation 'com.otaliastudios:cameraview:2.0.0-beta04'
and synced the project with gradle files and I still get unresolved reference
According to the documentation try to add:
api 'com.otaliastudios:cameraview:2.7.2'
For more information visit, https://github.com/natario1/CameraView

Why I am getting this "Could not find com.google.firebase:firebase-core:16.1.0." error all the time?

I am really fed up of these stupid android studio errors, the thing is I have included the implementation com.google.firebase:firebase-core:16.1.0 dependency in my build.gradle file but still am getting the error that says :::
Could not find com.google.firebase:firebase-core:16.1.0.
Also if I try to change it from 16.1.0 to 16.0.1 still error continues. How to fix this issue I have built almost 80% of my app and now when I just created new activity it is showing this error, I also deleted the activity but still issue continues. What is the fix for this? Thanks in advance!!
classpath 'com.google.gms:google-services:4.0.1'
And here is my Gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.2'
implementation 'me.anwarshahriar:calligrapher:1.0'
implementation 'com.firebaseui:firebase-ui-database:4.3.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-core:16.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
Could not find com.google.firebase:firebase-core:16.1.0"
It happens because firebase-core:16.1.0 doesn't exist (today).
You can check the latest version here. Currently it is 16.0.7
Firebase Core com.google.firebase:firebase-core:16.0.7
Change your dependency in:
implementation 'com.google.firebase:firebase-core:16.0.7'

dependencies error when add firebase libraries

When add firebase in
dependencies
implementation 'com.google.firebase:firebase-core:16.0.6'
Or
implementation 'com.google.firebase:firebase-ads:17.1.2'
Or
implementation 'com.google.android.gms:play-services-ads:17.1.1
It shows error under implementation 'com.android.support:appcompat-v7:28.0.0' that All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
When I sync the app no error but when install the app it shows you app has been stopped (Crashing during run time).
When remove the firebase dependencies and run, my app it's working fine.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
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'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
apply plugin: 'com.google.gms.google-services'
When you include dependencies, they too, will sometimes include dependencies of their own. Some of the firebase libraries happen to include support libraries at a lower version than 28. When you hover over the error message for appcompat-v7 it should tell you what library is lower than 28. You may have to click 'show more' on the error message. Once you figure out which one it is, include that exact same library but version 28. Resync your gradle and you're good to go. Also, you might have to do this multiple times because some firebase libraries include multiple lower version support libraries and the error message will only show you one library at a time.

android gradle //noinspection GradleCompatible

What does it mean in android gradle.
adding //noinspection GradleCompatible has resolve the conflict issue with dependencies.
You can get this warning for your gradle configuration for example if
your app code is mixing library versions.
A common example of this happening is with the Android support
libraries.
Also if additional 3rd party libraries included in your project are
using different versions, that can also present warnings.
Android Studio will show you details of the error message, before you suppress it with 'GradleCompatible' by hovering over the red warning line in the IDE (see attached screenshot).
'//noinspection GradleCompatible' just suppresses the warning.
Basically do not inspect issues with Gradle compatibility, as relates
to the next line of the config.
I had the same problem and finally I have added this line by pressing alt+enter, but before that check if the app compat library version is latest version that there is available for your app's target sdk version.
If that is okay and you are still getting the problem then do this by pressing alt+enter key (in ubuntu and windows) and (in mac os (os x) use command +shift +enter) add noinspection GradleCompatible this will help!
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}

Categories

Resources