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'
}
Related
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'
Type com.nikolam.nsdkelper.BuildConfig is defined multiple times: /storage/Users/Volks/Desktop/Android-2020/NsdKelper/app/build/intermediates/project_dex_archive/release/out/com/nikolam/nsdkelper/BuildConfig.dex, /storage/Users/Volks/Desktop/Android-2020/NsdKelper/nsdkelper/build/.transforms/6fff326acaa87110e65737aff5d0e0cd/classes/classes.dex
./gradlew test build outputs this
I have an App Module that implements my LibraryModule and thats it
These are the recommended fixes
This error typically occurs due to one of the following circumstances:
A binary dependency includes a library that your app also includes as a direct dependency. For example, your app declares a direct dependency on Library A and Library B, but Library A already includes Library B in its binary.
To resolve this issue, remove Library B as a direct dependency.
Your app has a local binary dependency and a remote binary dependency on the same library.
To resolve this issue, remove one of the binary dependencies.
These are the dependencies for the two build gradles of the library and the app.
dependencies {
///LIBRARY
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'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
///APP
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":nsdkelper")
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 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Apps whole build.gradle https://hastebin.com/dehedobica.php
Libraries whole build.gradle https://hastebin.com/omahuqutuc.nginx
I can remove the direct dependency and use JITPACK.io but I'd like to keep it local for development, I tried updating the dependencies, gradle version and downgrading versions but nothing seemed to work. I also deleted some dependencies but that didn't help either. I invalidated cache and similar common fixes but no luck.
I tried removing the dependencies from the App module and just implementing the Library(NsdKelper) but it doesn't work like the way I think it does. My way of thinking is
A implements project B which means that A will check B's dependencies and use those. But that doesnt seem to be the case here. Removing the dependencies from my App Module gives me errors of missing libraries. Or I am I misunderstanding something
They had the same Package ID, renaming the package on one of the modules solved it.
I have just started a new project with the latest version of Android studio 3.5.2. Min API - 19 and using SDK Q, which forces us to use AndroidX.
com.google.android.material.textfield.TextInputLayout
Giving error: Android resource linking failed.
With this setup, I am trying to user Material Component, but it is not working.
I am not sure if anything changed in AndroidX or Material component is already included or not. However, I have added the material dependency anyway.
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'
// here is the one
implementation 'com.google.android.material:material:1.2.0-alpha01'
}
So my issue is how can I use material components on this setup.
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.
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!