FCM integration in android, Why Firebase importing everything? - android

I have recently added FCM to my project and it's working fine. I have used
compile 'com.google.firebase:firebase-messaging:9.0.2'
this line for the library since messaging service is only required. But when I have seen the external libraries dir there are many firebase classes which have no use in my app. Please see the image below.
Edited : Here is the whole dependency clause
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.4.3'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
}
apply plugin: 'com.google.gms.google-services'

You are including more libraries than you need because you are using the general play-services library and not using the split libraries like play-services-drive or some other specific library.
By using play-services:9.0.2 you are saying you want to include all libraries in Google Play services including all the Firebase ones.
Removing the play-services:9.0.2 dependency and replacing it with a specific one like play-services-drive:9.0.2 (depending on what APIs you want to use) should fix your issue.

I believe since you don't add the core lib dependency explicity. The messaging dependency downloads all of the Firebase one.
Try adding the core and messaging both to limit the things to messaging part
compile 'com.google.firebase:firebase-core:9.0.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'

Related

what are the generic URLs need to be enable to add dependencies in Android project using proxy?

In my organization due security they restricted network like social media sites, other sites. Because of this, I am unable to add some Android dependencies in my project build.gradle.
Eg:-
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
But I am able to add default android dependencies like below.
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:multidex:1.0.1'
So, here my question is what are the generic URLs need to be enable to get all dependencies build.gradle. I will ask them to enable those URLs.
Thanks in advance
I believe URls are dependency specific, will very from one to other.
Why don't you configure your gradle for proxy?
Complete answer here

Android Studio Can't Fetch Library

I have recently started getting this issue with Android Studio and it has been driving me up the wall. I keep getting the error "Failed to resolve: com.squareup.okio:okio:1.8.0". These are the dependencies I have:
dependencies {
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile files('libs/okio-1.8.0.jar')
compile files('libs/retrofit-2.1.0 (1).jar')
}
As you can see, I have the retrofit and gson libraries simply compile (I'm assuming this downloads them from the internet), I tried doing the same with Okio however it didn't resolve, so I have speicifcally downloaded the 1.8.0 Okio JAR however it still fails to resolve. Why could this be? Any answer would be greatly appreciated. Thank you
Don't put dependencies as a Gradle dependency:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
And as a .jar file in src/libs:
compile files('libs/retrofit-2.1.0 (1).jar')
at one time. Choose only one method. I advise you to choose Gradle dependencies, because they are automatically fetched.
In you case, the dependencies section should look like:
dependencies {
compile `com.google.code.gson:gson:2.7`
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
}

Compile time error for setServiceAccount() with FirebaseOptions.Builder()

I was working my Android app for sending push notifications using Firebase cloud messaging. I was setting up my server referring the guide https://firebase.google.com/docs/server/setup#prerequisites.
My project level build.gradle is like :
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
App level build.grade :
dependencies {
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:geofire:1.1.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'
compile 'com.google.firebase:firebase-core:9.0.0'
}
I have created the service account credentials on the console as well but while I am initializing the SDK referring https://firebase.google.com/docs/server/setup#add_the_sdk
FirebaseOptions options = new FirebaseOptions.Builder()
.setServiceAccount
(new FileInputStream("path/to/serviceAccountCredentials.json"))
.setDatabaseUrl("https://databaseName.firebaseio.com/")
.build();
I am getting compile Error:(116, 21) error: cannot find symbol method setServiceAccount(FileInputStream)
I have checked many places but I am unable to find what I am doing wrong. Any help would be highly appreciated.
In your server project you need to use only the dependency:
com.google.firebase:firebase-server-sdk:[3.0.0,) and remove:
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
The first is a server sdk while the others are client sdk and they will have conflicts if you try to use them together.
You're including a different version of the Firebase Database SDK than what you have for the other Firebase features:
compile 'com.firebase:firebase-client-android:2.5.2'
If you change it to:
compile 'com.google.firebase:firebase-database:9.0.0'
It will work better.
For more information, see the Firebase documentation for Android developers, from where I copied the line above.

Android studio getting stuck when run project

I have update the google play service version to 7.+, this version is required for GoogleApiClient, After updating google play version when i run project it will take much time and stuck entire computer.
Please guide.
thanks
Make sure to use required Google API in project. What you need in your project.
dependencies {
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-base:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
}
Note: Do not use complete google dependencies
dependencies {
compile 'com.google.android.gms:play-services:8.3.0'
}

How to import SupportPlaceAutocompleteFragment into an Android Studio project

I need to use Android's SupportPlaceAutocompleteFragment in a project, but for some reason Android Studio complains that Can not resolve symbol SupportPlaceAutocompleteFragment. Am I missing something in my gradle file:
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
I checked the documentation here but there was mention of which library is required to use this fragment.
SupportPlaceAutocompleteFragment requires Google Play Services 8.4 and you are using Google Play Services 7.5.0
Use :
compile 'com.google.android.gms:play-services:8.4.0'
or
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
Reference : New AutoComplete Widget.
Here is Sample Project for implementing the same.
From what I could gather from a quick look at the documentation, you might be missing the Android Support Library reference in your project. Go to tools->Android->SDK Manager and under extras check if you have the Android Support Library installed, if not install it. Also, add a reference to it in your gradle file like this compile 'com.android.support:support-v4:23.1.1'.

Categories

Resources