Android Studio dependency incompatible - java

I just want to know how to fix this issue with incompatibility with dependencies on android studio. I am trying to follow the steps on setting up firebase but could not find any solution with this incompatibility. Please help

That is because Firebase libraries is using support libraries implicitly. You need to override the incompatible libraries by adding the clashed support libraries but with the same current version. For your case, you need to override support-media-compat. You can add the following dependencies to your dependencies block:
dependencies {
implementation "com.android-support:support-media-compat:28.0.0"
implementation "com.android-support:animated-vector-drawable:28.0.0"
implementation "com.android-support:support-v4:28.0.0"
...
}

Related

Could not find androidx.camera:camera-view

I am developing a basic custom camera app
These are my dependency
// CameraX core library dependency
implementation "androidx.camera:camera-camera2:$camera_version"
// CameraX Lifecycle dependency
implementation "androidx.camera:camera-lifecycle:$camera_version"
// CameraX View dependency
implementation "androidx.camera:camera-view:$camera_version"
camera_version = '1.0.0'
Getting below error, it work fine if I remove camera-view dependency, but I cannot as I need that for my custom camera app.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find androidx.camera:camera-view.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/androidx/camera/camera-view/1.0.0/camera-view-1.0.0.pom
- https://repo.maven.apache.org/maven2/androidx/camera/camera-view/1.0.0/camera-view-1.0.0.pom
Required by:
project :app
As Morrison Chang already helped you with current issue.
I just wanted to add a few pointers to that whenever you get any such error in future for any of the android's library.
Search google's maven repo https://maven.google.com/ to see if the version you are looking for is even the correct one or what is the latest version of the library exists. like in your case https://maven.google.com/web/index.html?q=camera#androidx.camera:camera-view
Few of the library is still available at https://mvnrepository.com/ where you can check the version of your library

No variants of io.grpc:protoc-gen-grpc-java:1.33.1 match the consumer attributes

Issue:
I'm using Dexguard to obfuscate codes for release build.
Previously, I could build as normal without errors.
However, when I add this dependency com.github.hyperledger:iroha-java:7.0.0, the release build process failed with an error in the screenshot below:
I guess the library internally depends on io.grpc:protoc-gen-grpc-java, but somehow Dexguard SDK can't find the dependency with the correct artifactType = dexguard-consumer-rules.
What I have tried:
adding io.grpc:protoc-gen-grpc-java:1.33.1
downgrading/upgrading version of iroha-java
Now I am not sure if the problem is caused by Dexguard or the iroha-java library.
So in case you have experiences related to this issue, please guide.
Dexguard can be causing the issue. In our experience it might be beneficial to just set up some rules within it so it would avoid the library. That should work.
In case someone also faced this error:
The solution is to downgrade iroha version to 5.2.1 and exclude io.grpc from it.
implementation('com.github.hyperledger.iroha-java:client:5.2.1') {
exclude group: 'io.grpc', module: 'protoc-gen-grpc-java'
}

Error while building project : Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy

I'm trying to keep my current SDK version as 27 and don't want to upgrade to AndroidX. What can be the solution for this error?
Error highlihted
This issue, is because of partial AndroidX implementation.
Seeing the dependency you already are doing androidx partially, see the code
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Either change the dependency from AndroidX to old one like
implementation 'com.android.support:recyclerview-v7:27.0.0'
by following the guide over here https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
Which is basically, find the implementation you have in your build.gradle and finding it over there in table, and copy pasting the one on left side.
Or go to Refactor -> Migrate to AndroidX and convert whole code to AndroidX.

Android Studio not excluding a transitive dependency and complains about class conflict

Hi I'm working on an Android app and I need to use a library called Semantics3. The issue I'm having is that the Semantics3 library depends on a few different libraries one of which is org.json but Android Studio automatically includes its own unique version of org.json which causes various issues. I've tried a few things to work around this and I'll describe them below.
First, I just imported the Semantics3 library. All the code compiles but when code from the library runs to make a service call the app crashes. This is due to a "NoSuchMethod" error because Semantics3 makes use of a constructor from a class in org.json which the AS version doesn't include.
To get around this I made my own jar file of the Semantics3 code and add in the dependencies it needs on my own in Gradle. The app still crashes, though not because it can't find the constructor. In this case the error is due to an exception from org.json, specifically "org.json.JSONException: Value com.android.okhttp.internal.huc.HttpURLConnectionImpl of type java.lang.String cannot be converted to JSONObject". I couldn't figure out why this error was popping up so I decided to try out the Semantics3 library outside of Android and just made a simple Maven project. In the Maven project I can make service calls just fine with no issue, but if I add the jar file and dependencies on my own, I get the same error as in AS.
So I figure there's something missing in the source code on Github that I used to make the jar or something but that's beyond me to figure out, so I'm back at trying to just import the library. My final and current attempt involves trying to explicitly import the version of org.json that Semantics3 needs along with the Semantics3 library in Gradle. But when I bring in the Sematnics3 library I try to exclude the transitive dependency Semantics3 introduces to org.json. I've included the Gradle file for this attempt below.
// https://mvnrepository.com/artifact/com.semantics3/Sem3Java
implementation('com.semantics3:Sem3Java:1.2.4'){
exclude group:'org.json:json'
}
implementation 'org.json:json'
constraints {
implementation(group: 'org.json', name: 'json', version: '20190722') {
because 'Semantics3 requires version 20190722 of org.json, not the default AS version'
}
}
The issue is when I try to run the code with the above setup in Gradle I get an error saying there are duplicate class definitions contained in the Semantics3 library and org.json library. And yes there are certainly conflicts but I thought the exclude bit to the Semantics3 implementation would be enough to prevent that from happening. Did I make a mistake somewhere or am I misunderstanding or misusing the exclude? If it makes a difference it appears the Semantics3 library does hardcode the org.json library into its Jar file. I appreciate any help with this. Thank you.

Android compilation error after upgrading to 'com.google.android.gms:play-services-ads:18.1.0'

I am upgrading my play-services-ads library from version 12 to version 18.1:
dependencies {
api 'com.google.android.gms:play-services-ads:18.1.0'
}
The problem is that the compilation fails with this error:
.gradle/caches/transforms-1/files-1.1/play-services-ads-identifier-17.0.0.aar/75b3c9fbdc51199269673bd2fa8b6cfe/jars/classes.jar(com/google/android/gms/ads/identifier/AdvertisingIdClient.class): warning: Cannot find annotation method 'value()' in type 'GuardedBy': class file for javax.annotation.concurrent.GuardedBy not found
I took away all the usages for AdvertisingIdClient and left only the import, but the problem persists:
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
Is there anything I am doing wrong?
com.google.android.gms:play-services-ads:18.1.0 depends upon com.google.android.gms:play-services-ads-identifier:17.0.0, among other libraries.
Your error indicates that com.google.android.gms:play-services-ads-identifier:17.0.0 references javax.annotation.concurrent.GuardedBy. However, that class is not in the Android SDK. The POM file for com.google.android.gms:play-services-ads-identifier:17.0.0 should be referencing a library that has an implementation of that class, but it does not seem to.
One library that has an implementation of that class is com.google.code.findbugs:jsr305. Adding a dependency on com.google.code.findbugs:jsr305 for a recent version (e.g., 3.0.2) gave you that class, satisfying the compiler.
So, there appears to be a bug in the Play Services SDK packaging, which my workaround resolves. You might want to add a comment in your module's build.gradle file to consider removing the com.google.code.findbugs:jsr305 if a future update to com.google.android.gms:play-services-ads fixes this bug.

Categories

Resources