I added the mapbox-search-ui dependency to my app/build.gradle following the instruchtis here: https://docs.mapbox.com/android/search/guides/search/
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0"
implementation "com.mapbox.navigation:android:2.7.0"
implementation "com.mapbox.search:mapbox-search-android-ui:1.0.0-beta.38"
The build then fails with "Duplicated class found"
Duplicate class com.mapbox.common.MapboxCommonLogger found in modules jetified-base-10.7.0-runtime (com.mapbox.maps:base:10.7.0) and jetified-common-23.1.0-rc.1-runtime (com.mapbox.common:common:23.1.0-rc.1)
Build is fine without the mapbox-search-android-ui package.
I tried to determine and exclude the faulty package but without success.
Any suggestions warmly welcome
EDIT
The issue also happens when i just want to add the core search library:
implementation "com.mapbox.search:mapbox-search-android:1.0.0-beta.38"
So i assume that the issue is caused by using the "old" mapbox sdk version 9.5.0. When i switch to the current 10.9.0 version i don't get the duplicate classes error. But then i would need to migrate my whole code to 10.9.0 which means a lot of effort...
EDIT 2
As of an answer to a corresponding issue i openend on their guthub page the devs told me that the search SDK currently not works with Mapbox v9, but they maybe consider to add backward compatibility.
see https://github.com/mapbox/mapbox-search-android/issues/93
Related
I am trying to integrate admob into my app but I keep getting this strange error that says
Duplicate class com.google.android.gms.common.api.internal.zza found
in modules jetified-play-services-base-11.6.2-runtime.jar
(com.google.android"attached is my build.gradle file.
(com.google.android.gms:play-services-base:11.6.2"
The error usually appears when one of the modules that you include in your project has inside another library that you are including in your main project as well. My recommendation is to first update the version of the libraries that are highlighted. Then try to remove this and check if everything works:
implementation 'com.google.android.gms:play-services-ads:18.3.0'
Or if you have access to the gradle file of the module remove 'play-services-ads' there
I am using gradle dependency of
implementation 'com.google.android.gms:play-services-location:15.0.1'
at runtime I get below error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/location/LocationRequest;
I am trying to fetch lat long using LocationRequest and when I am using this code in a standalone project it works. And when I am trying to build a library with same code I get above error.
I have checked, both standalone project and library project have same dependencies and versions.
This maybe because of 2 reasons
1st possible reason
When you used this library directly you used implementation method in build.gradle.
So you can use it directly in simple app module.
When you move it to your library and use that location library using same implementation option that location library can be only used by your library. and can't be used by app module in which you have used your library
Try by replacing that implementation by api for location library like this
api 'com.google.android.gms:play-services-location:15.0.1'
For more details refer this post for implementation vs api - Here
2nd possible reason
As you mentioned in comments, its a runtime error
As per my opinion it maybe because of obfuscation by ProGuard
add that class to keep ProGuard rule like this
-keep class com.google.android.gms.location.** { *; }
So this will stop obfuscation of that Location Request class
The code is working now with below changes (I am still looking for an explnation)
in the library gradle edited to below dependency
compileOnly "com.google.android.gms:play-services-location:15.0.1"
and in the app's gradle file added below dependency
runtimeOnly 'com.google.android.gms:play-services-location:11.6.0'
my guess is, since "compileOnly" takes care of adding the dependency in library and "runtimeOnly" takes care of using that dependency the code works and is able to find LocationRequest class.
P.S adityakamble49 's answer in the thread also helped. Please try that as well as it might work for your case.
Previously my gradle used to look like this and worked fine (apart from few registered bugs)
implementation 'com.dji:dji-sdk:4.3.2'
Now, after changing to
implementation 'com.dji:dji-sdk:4.4.0'
the Camera and other files cannot be recognized anymore. I am attaching a screenshot of the unrecognized imports.
However when I am trying to add
//dji-drones-sdk
implementation 'com.dji:dji-sdk:4.4.0'
provided 'com.dji:dji-sdk-provided:4.4.0'
I am getting "could not download dji-sdk-provided.jar"
Screenshot attached
All the examples and github codes are in version 4.3.2. Can anyone help me out?
Here is the link to the dji sdk
I have found the issue. After Gradle 3.4, the "provided" is replaced by "compileOnly"
I quote,
Gradle adds the dependency to the compilation classpath only (it is not added to the build output). This is useful when you're creating an Android library module and you need the dependency during compilation, but it's optional to have present at runtime. That is, if you use this configuration, then your library module must include a runtime condition to check whether the dependency is available, and then gracefully change its behavior so it can still function if it's not provided. This helps reduce the size of the final APK by not adding transient dependencies that aren't critical. This configuration behaves just like provided (which is now deprecated).
Hence using compileOnly in place of provided will do the trick.
Here is a link to the gradle changes documentation
I am trying to run Espresso tests (written in Kotlin) in Android Studio with the AccessibilityChecks enabled as documented here.
When I try using AccessibilityChecks within the tests, I get the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/Preconditions;
at android.support.test.espresso.accessibility.AccessibilityChecks.enable(AccessibilityChecks.java:80)
If I try moving it to a Before class like mentioned in the documentation:
Then it will fail with the error 'Empty test suite':
There are two issues reported here:
Package 'com.android.support.test.espresso:espresso-accessibility:3.0.0' uses
a Guava class but does not declare a dependency to Guava, resulting
in the errors reported in comments #1-#5.
Package 'com.android.support.test.espresso:espresso-accessibility:3.0.1'
seems to have duplicates of the
android/support/test/espresso/accessibility/R class, resulting in the
error in
Both issues have been fixed and will be included in the 3.0.2-alpha2 release
If any issue persists, please report at Google issue tracker they will re-open to examine.
I had to add to add the guava dependency to my app gradle file using:
androidTestCompile 'com.google.guava:guava:20.0'
I also opened a ticket for Android at:
https://issuetracker.google.com/issues/65486414
To support Instant Run in my version of Android Studio, I needed to upgrade my Gradle plugin from version 2.2.3 to 2.3.3
I'm aware I'm supposed to migrate to annoationProcessor and I believe I've followed that guide correctly
after doing so, the Android DataBinding code generation fails
The migration guide linked earlier states that all I need is to
Make sure you are on the Android Gradle 2.2 plugin or newer
Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format
This should be all that's needed to successfully build the project. Yet it doesn't build.
Build output
Gradle build finished with 101 error(s) and 23 warning(s) in 12s 481ms
All of the errors follow the same pattern:
C:\Users...\FooAdapter.java
error: package com.example.app.databinding does not exist
error: cannot find symbol class ItemFooBinding
An interesting message can be found in the build console:
Warning:The following options were not recognized by any processor: '[android.databinding.minApi, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir, android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.isTestVariant]'
I would like to point out that...
I presume I don't have an error in some XML file, binding expression or a naming issue. The same set of sources and XML build when I switch back to the Git branch with the old gradle plugin version (and all of the other source files up-to-date)
I did increase the limit of output build errors as discussed here, although this doesn't seem to be relevant right now, since as you can see, I currently have "only" 101 errors. :)
Additional info
The following diffs show how I've modified my gradle files:
build.gradle DiffChecker link
app/build.gradle DiffChecker link
Also, as a quick overview, here is the list of some of the "more interesting" plugins & libraries used by the project:
Kotlin
Android DataBinding
Realm
Retrofit
Dagger
ButterKnife (I know...)
Multidex Support Library
Does anyone have a clue what could be the issue? Any help or idea will be greatly apprecitated!
I had exactly the same warning. This line in gradle solved the issue:
kapt "com.android.databinding:compiler:3.0.1"
Hopefully, it will help somebody
Update:
3.0.1 is Android Plugin Version.
When you see innumerable build errors mentioning databinding as in this case, the problem usually lies somewhere else. Databinding just gets stopped in its tracks by unrelated build problems and complains exceedingly loudly. The only way to deal with it is to locate the build errors that are not tied to databinding. Once they are fixed, databinding can do its thing again and be silent. Unfortunately you often have to repeat this approach several times until you have found all non-databinding issues. It's an arduous task for sure, but unfortunately there is nothing else you can do until Google manages to provide a saner build environment.
This is the reason why you are advised to increase the build error limit beyond 100 - you would not see the actual errors causing your problems, because they commonly do not show up early in the list.
I will chance a guess - Dagger 2 is a common source of triggering this problem, which could be related to your annotationProcessor change; so look out for Dagger errors. But your issues could be caused by other things, like other annotation processors as you mentioned - you wouldn't know for sure until you diligently dig through your build errors.
It seems it all comes down to my project using Kotlin. Actually we have it mixed: some classes use plain old Java while others are written in Kotlin. An incomplete migration. :)
I assume that without Kotlin, replacing apt with annotationProcessor would be enough and I wouldn't have ran into this issue at all.
Solution
Annotations need to be processed by both annotationProcessor and kapt, which seems to be Kotlin's own annotation processor.
For each Gradle dependency that uses annotations, you should have both of the following in your app-level build.gradle:
annotationProcessor 'com.example.my.library:x.y.z
kapt 'com.example.my.library:x.y.z