Android manifest merger with facebook and firebase libraries - android

I've imported in my project 2 libraries (in gradle file):
...
/* Firebase UI */
compile 'com.firebaseui:firebase-ui:0.4.0'
/* Facebook login */
compile 'com.facebook.android:facebook-android-sdk:4.13.0'
but when building my project I have the following error:
D:\Android\Projects\quoter\app\src\main\AndroidManifest.xml:68:13-58
Error: Attribute activity#com.facebook.FacebookActivity#theme
value=(#style/FirebaseUI.Translucent) from
[com.firebaseui:firebase-ui-auth:0.4.0] AndroidManifest.xml:68:13-58
is also present at [com.facebook.android:facebook-android-sdk:4.13.0]
AndroidManifest.xml:32:13-72
value=(#android:style/Theme.Translucent.NoTitleBar). Suggestion: add
'tools:replace="android:theme"' to element at
AndroidManifest.xml:64:9-68:61 to override.
I found the expanded jars with the manifest files for both Facebook sdk and Firebase UI libraries, but I'm not sure that changing them it's the right way to solve this error because each time I clean and re-build my project new manifests are also generated...
How can i solve this error? It seems to me an incopatibility between the 2 libraries...
Note: adding in my app manifest the following
<application
tools:node="replace"
solve this problem, but it's impossible to launch the app because Firebase it's not correctly initialized (see https://stackoverflow.com/a/38060272/6503817)

FirebaseUI already compiles Facebook for you, so when you try to sync it basically throws the error because you are trying to compile the same thing twice.
Remove compile 'com.facebook.android:facebook-android-sdk:4.13.0' and keep: compile 'com.firebaseui:firebase-ui:0.4.0'
and you are done!
Don't worry! You will still have Facebook Login

Unfortunately, "tools:replace" didn't work for me, but a GitHub issue in the Firebase UI has a solution https://github.com/firebase/FirebaseUI-Android/issues/230
But FirebaseUI already depends on version 4.11.0 of the SDK. Can you try removing your Facebook dependency and just relying on the transitive dependency brought in by FirebaseUI?

I would recommend you go through the documentation once, provided FirebaseUI Android and FirebaseUI Auth Android. They are pretty thorough and most likely will curb your doubts.

Related

Issue with DJI SDK gradle 4.4.0, provided keyword in gradle not working

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

How to get a compile error if a JAR dependency is missing?

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 :)

Adding Firebase UI to android studio

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

Android Studio - Cannot resolve symbol 'firebase'

I'm currently upgrading an app to the new Firebase version. I followed the guide, included classpath 'com.google.gms:google-services:3.0.0' in the dependencies of my project build.gradle as well as compile 'com.google.firebase:firebase-core:9.0.1' among others in the dependencies of my module build.gradle and also apply plugin: 'com.google.gms.google-services' at the end of that file.
I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.firebase.database.DatabaseReference;. Those are not errors that appear when building, so this seems to be working, but they are visible in the code editor of Android Studio.
The imports worked just fine a couple of days ago (except for FirebaseAuth, which was under maintenance). I did not change anything about the code since then (except trying to upgrade to 9.0.2, which lead to the same result). The only thing I did was update some components of the Android SDK, but I can't remember which. The Android SDK as well as Google Repository and Google Play Services are of the newest version. Rebuilding, cleaning and invalidate caches / restart had no effect.
Any ideas how to fix this?
You need to add this dependency in your build.gradle(app)
compile 'com.firebase:firebase-client-android:2.5.0'
Now with New Android Studio ,Its so easy to add Firebase to your Project.
Below are Simple Steps-
1. On Android Studio’s Tools menu, you’ll see an entry that reads Firebase.
2. Select this, and a Firebase Assistant pane will open to the side of your code editor:
3. On this pane, click the arrow beside ‘Authentication’, and you’ll see a step through for ‘Email and Password Authentication’.
4. Click the ‘Connect to Firebase’ button.
Your browser will open with a ‘Request for Permissions’ dialog:
5.Click ‘Allow’, and then after a ‘Success!’ screen, you’ll be given a dialog with which to connect to Firebase.
6.You will see Connected .Its Done !
For more on Firebase refer here.
You can open and use the Assistant window in Android Studio by following these steps:
Click Tools > Firebase to open the Assistant window. And it will guide you for sync firebase and your project.
Make sure you fulfill the following prerequisites before adding firebase to your project.
For working with Firebase you should install Android Studio 1.5 or higher.
Download the latest Google Play services SDK from through Android SDK Manager.
The device should be running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.0 or newer.
I find out all this after hours of struggle, so thought of sharing with others.
Source: Adding Firebase to your Android App
Invalidating cache didn't work for me. But deleting .idea/libraries worked like magic.
More info here: https://stackoverflow.com/a/50129167/971972
Add following in your gradle file under dependencies:
compile 'com.firebase:firebase-client-android:2.5.2'
If you are getting a build error complaining about duplicate files you can choose to exclude those files by adding the packagingOptions directive to your build.gradle file:
android {
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
To use the Firebase Messaging service you need to add the following dependencies to your app's build.gradle file:
compile 'com.google.firebase:firebase-messaging:9.4.0'
I had the same problem but thanks to this answer:
https://stackoverflow.com/a/39353961/4836759
In the new SDK, it's no longer necessary to call Firebase.setAndroidContext() so you can remove it from your code.
In the new SDK, Firebase references are replaced by DatabaseReference and you use the FirebaseDatabase class to get an initial reference to your database. So you can get the database reference in your code as follows:
BEFORE
Firebase rootRef = new Firebase("https://.firebaseio.com/");
AFTER
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Note that your Database URL is automatically determined from the google-services.json file you downloaded, so you don't need to specify it. If you want to specify it though, you still can (which might be convenient for migration purposes):
BEFORE
Firebase ref = new Firebase("https://.firebaseio.com/path/to/data");
AFTER
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReferenceFromUrl("https://.firebaseio.com/path/to/data");
22
After adding it in from the built in Firebase tool and also following the following a tutorial, the imports did not work on one of my classes so all you have to do is sync the gradle files
Tutorial I've used:
https://www.androidtutorialpoint.com/firebase/firebase-cloud-messaging-tutorial/
Tools/Android/Sync Project with Gradle Files.
Works 100% now
You need the Firebase client library. Add this to your app gradle:
dependencies {
// Firebase
implementation 'com.firebase:firebase-client-android:2.5.2'
Replace 2.5.2 with the latest version (there is probably a new one out there since I posted this answer).
dependencies should be used in the latest gradle version (not compile).

Instabug error:- Manifest merger failed : Attribute activity#com.instabug.library.InstabugFeedbackActivity#windowSoftInputMode

I am using Instabug with URBAN AIRSHIP getting the following error
Error:Execution failed for task ':app:processReleaseManifest'.
Manifest merger failed : Attribute activity#com.instabug.library.InstabugFeedbackActivity#windowSoftInputMode value=(adjustResize) from [com.instabug.library:instabug:2.0] AndroidManifest.xml:29:13-55
is also present at [com.instabug.library:instabugcore:1.7.4] AndroidManifest.xml:18:13-52 value=(adjustPan).
Suggestion: add 'tools:replace="android:windowSoftInputMode"' to element at AndroidManifest.xml:25:9-29:58 to override.
I go through
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
and
Tools: replace not replacing in Android manifest
But didn't get any solution
//EDITED
already tried
tools:replace="android:windowSoftInputMode"
No solution yet
Suggestion: add 'tools:replace="android:windowSoftInputMode"' to <activity> element at AndroidManifest.xml:25:9-29:58 to override.
HOW SHOULD I USE IT?
Hello MobilityNewTech,
Seems like you have 2 different versions of Instabug imported (namely 1.7.4 & 2.0)
from [com.instabug.library:instabug:2.0] AndroidManifest.xml:29:13-55 is also present at [com.instabug.library:instabugcore:1.7.4]
If you can post your build.gradle maybe I can help you fix this issue.
I've just started to use Instabug and a problem the same as yours occured when I used following dependency:
compile 'com.instabug.library:instabug:2+'
compile ("com.instabug.library:instabugsupport:+") {
exclude group: 'com.android.support'
}
instabug dependency was used because my app minSdk +14 and instabugsupport was used as a solution to following question:
Is there a way to prevent Instabug from pulling the latest version of AppCompat?
from FAQ below configuration section.
Problem dissapeared when I changed it to it:
compile('com.instabug.library:instabugcompat:2.0.1')
I think Instabug should update whole configuration section - especially a part about using support libraries - e.g. when you're using Instabug 'developer console' to integrate your app with Instabug, it isn't clear, what dependency should I use when I'm using support libraries in app set for minSdk +14. Moreover, when you choose 'Support library', they prompt you to extend there Instabug***Activities, but Android sample hosted on github.com says that you should extend their activities class only when you app minSdkVersion is +10.

Categories

Resources