I'm going to implement Sentry.io Log Service in my Android App.There is a comment in it's installation guide which says:
// this dependency is not required if you are already using your own
// slf4j implementation
compile 'org.slf4j:slf4j-nop:1.7.25'
I don't know I should add this dependency or not.
Does Android use it's own slf4j implementation?
As Henry said in comments, Android doesn't include an slf4j implementation, So I Should Add this dependency to get ready to setup Sentry.
Related
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.
I'm pretty new to android studio, but i got this error and i can't run my project. I saw a lot of answers which suggest to add the support-annotations dependency, but I'm using appcompat so i don't need that. Any thoughts?
Do you have the Android Support Library?
To do it add this to your build.gradle file of the "app" module:
dependencies {
...
implementation "com.android.support:support-annotations:27.1.0"
}
Then sync the project.
Sometimes you can do this automatically by pressing Alt+Enter over the error message and selecting the solution.
You need to fetch the libraries that contain the imports, in your build gradle file of your module add the line inside dependencies tag:
api 'com.android.support:support-annotations:X.X.X'
or
implementation 'com.android.support:support-annotations:X.X.X'
Where X.X.X is the version of the rest of your support libraries.
You should read this article that explains how to implement this with more detail.
I have an Android project with the following dependencies:
-- Android App
---> MySDK.Jar
------> 'org.apache.commons:commons-lang3:3.5'
This is MySDK.jar that has a dependency on commons-lang3.
I'm working on Android Studio and I'm thus using Gradle.
Here is my problem:
I have shared "MySDK.Jar" to someone and he has built his own Android App on top of it.
It works but we have seen that the compiler doesn't notice the missing dependency on 'org.apache.commons:commons-lang3:3.5'. At run-time there will be a crash if the code using 'org.apache.commons:commons-lang3:3.5' is called. One may not notice the problem if he doesn't call the code using this library.
I know that we can solve this issue by adding the following line to Android App build.gradle file:
compile 'org.apache.commons:commons-lang3:3.5'
I'm wondering if there is a way to get a compile error indicating such missing dependencies? It is indeed better to see the dependency problem at compilation time rather than at runtime.
What are the recommended good practices for this?
Thanks!
commons-lang3 is a transitive dependency of Android App. As such, it is often not needed for compilation - there are exceptions, especially regarding multiple levels of inheritance. So at compile time you (usually) do not know whether you miss a transitive dependency that you need at runtime.
This is where Gradle comes in. Gradle can (as Maven) resolve dependencies transitively from a Maven repository (as MavenCentral). If you put MySDK into a Maven repository (like Nexus or Artifactory, which have open source versions), everyone using MySDK will automatically draw commons-lang3 so you will not miss anything at runtime.
If you are just adding the jar file in your project you can't warning about the missing dependencies.
To do it you have to publish the jar file in a maven repo.
In this way you have a pom file which describes the dependencies that gradle has to download.
Provide a method like MySDK.init() int your MySDK.jar,call a method whe is belong to org.apache.commons:commons-lang3:3.5' in the MySDK.init() method, then put init() into onCreate() of your Application,
Another way is,putorg.apache.commons:commons-lang3:3.5 into MySDK.jar,
Hope it helps you :)
I need to get a hands-on on firebase list and recycler adapters. I've added the required firebase ui dependency but for reasons unknown to me, I keep getting this error:
Failed to resolve: com.firebase:firebase-ui:0.3.1
I've throttled the dependency version back and forth(0.1.0,0.3.1, 0.4.0) and neither of them works for me. I could use some help here.
What is the google play services version of yours.
if 9.8.0, use below for compatibility reasons
compile 'com.firebaseui:firebase-ui:1.0.0'
https://github.com/firebase/firebaseui-android#using-the-library-in-your-android-app
In the app's build.gradle I add to the firebase core library to the dependencies :
compile 'com.google.firebase:firebase-core:9.8.0'
Then depending which modules of firebase I want to use in addition, I add those in too, such as:
compile 'com.google.firebase:firebase-ads:9.8.0'
To use FirebaseUI, you need to add some dependencies:
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
// Required only if Facebook login support is required
implementation('com.facebook.android:facebook-android-sdk:4.33.0')
// Required only if Twitter login support is required
implementation("com.twitter.sdk.android:twitter-core:3.1.1#aar") { transitive = true }
Here is more information: FirebaseUI-android
I am implementing Google plus login system to my android app by following the tutorial of google developer at https://developers.google.com/identity/sign-in/android/sign-in
According to the tutorial, I should implement:
GoogleApiClient.ServerAuthCodeCallbacks
interface to enable server-side API access for the android app. However, 'ServerAuthCodeCallbacks' interface does not exist in the GoogleApiClient library, even in the latest version of the library.
Does anybody have the same issue? Or, am I missing something?
Any input will be greatly appreciated!
See the example implementation on GitHub: github.com/googleplus/gplus-quickstart-android
Your dependency on com.google.android.gms:play-services must be at least of version 7.0.0 (currently latest is version 7.5.0)
Class itself is currently placed in package com.google.android.gms.common.api in Maven sub-dependency play-services-base
So for example like this:
dependencies {
compile 'com.google.android.gms:play-services:7.5.0'
}
Also see current Developer documentation here:
https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project