Configure Firebase SDK in multivariant project - android

I tried to add Firebase to existing project with quite complex setup (2 variants, +2 dev) and was wondering, how google-services.json should be used? Is there manual way of adding service config? I had the same problem with GCM, it works fortunatelly but I spent quite some time digging on stackoverflow.

There's a new post on the Firebase blog about the relationships between apps and projects, and how that relates to your Android build variants. Hopefully it will demystify how things work. At the very least you should know that you can have all your Firebase apps defined in a single google-services.json that can apply to each of your variants (if they're all in the same project), or you can put a whole different google-services.json file in your project for each variant, if they are in different projects.

Do you use Android Studio?
You use Android Studio and Gradle and then
you can use google-services.josn file.
The google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module)
You can set both GCM and FCM .
The Google Services Gradle Plugin

Related

how to implement one google-service.json file in to multiple android project

I working on a project that develops android .apk files using phone gap.
I use different them to manage my mobile app or when it builds the app I've changed its package id in my repo. I want to use push notification in all my generated apps. I can't manually add every time google-service.json in my repo or not wan go again and again on google console to add a new project with Package Id.
You should download each play-services.json files from each project and when you build your project you should add a script or a task to swap between the files.

Is it better to upload an android library to GitHub than keeping it inside the project?

I'm really new with android developing. But I know how to upload a library to GitHub and include it in an android project. Recently, I'm working on some android apps, and I realized that I need to use some layouts and classes for all the apps. So, I created an android library and kept that inside all the project files. Then I came to know that I can simply upload that library to GitHub and use it for all the projects. But I'm not sure if it's a good idea. Is there any advantage if I upload it to GitHub?
In general, using a source control (git or other ones) is always a good idea given that your local filesystem can crash or you may want to revisit certain revisions you made to your project. Github is very popular and hosts several highly used projects, so it is no doubt a good place to upload. However, you must know that if you don't have their paid account, the project will be public (at this time, free accounts don't have a way to create private projects). Are you developing as hobby and do you mind if others see / take the code and reuse (hopefully under the licensing terms you specify)? Or is that something you're doing for an employer? In that case you should consult with the employer if this is OK.
Now as for sharing this module across projects, I don't think github has a secret sauce here. You could always build your library once and drop it in as dependency into all your apps, without having to copy its source code into each project. You may also want to look into integration with maven / gradle build systems, which Android Studio uses. For example, third party libraries often are available as downloadable libraries from maven central, and you can add a couple of lines to your build.gradle to go fetch a specific version of your library from maven central, rather than manually adding that library jar to the project that is using it. If your library code is on github, there are ways to publish to maven central from github ( http://datumedge.blogspot.com/2012/05/publishing-from-github-to-maven-central.html ) but I don't have experience with that step.

Connecting different Android project to an existing Google-Endpoints Backend

I am working on an Android project that needs three versions of the same application (for example: Admin version, User version, Custom version). I have already created a Google-App-Engine endpoints backend in the User version of the app. I have to start working on the other two versions now and I want to connect these two versions to the backend I created in the User version. I have tried finding the answer to this on the internet but I haven't been successful in doing so. I believe it is possible to connect the other versions of the app to the backend by importing the endpoint libraries from the cloud into the android projects somehow but I haven't been able to find a way to do so yet.
I did come across a way to import an existing module in the Android project but if I do that, then any time when I make changes to the backend in the "User" version, I will have to re-import the module in other versions of the app. I am so lost and confused.
Any help will be deeply appreciated.
Thank you!
After you build your cloud module there is a YOUR_CLOUD_MODULE_NAME-android-endpoints.jar under YOUR_CLOUD_MODULE_NAME/build/libs.
You can copy this jar into libs directory of all your android projects that need to interact with your back-end.
This approach makes it really easy to get out of sync though. After every change to back-end you would need to update the .jar in all dependent modules.
Are all of your Android applications in the same Android Studio project? If so I think you might be able to just add
compile project(path: ':{yourBackendModuleGoesHere}', configuration: 'android-endpoints')
to each of your Android apps build.gradle.
You could probably also make it work even if your backend is in a separate AndroidStudio project as long as they're part of the same gradle build.

Error When building a large Codename One Application During the Dex Phase

I got an error in the build server when sending an Android build during the dex phase.
Googling a bit I learned that there is a hard limit of 64K functions (including all libs, the heaviest is google play services), or you can use the multiple dex mechanism.
How do I activate this for Codename One?
I understand Codename One uses Ant and as far as I understand this only works for gradle.
FYI this is the workaround, that splits google play services into sub libraries with native android:
http://android-developers.blogspot.com.es/2014/12/google-play-services-and-dex-method.html
I had a very similar issue and corresponded with Codename One's pro support on this. Gradle support was something they just recently announced so its not as documented but should be available in the next update.
You need to add the following build hints to your project:
android.gradle=true
android.multidex=true
I understand that gradle will be the default build once 3.3 rolls around so in the future only the multidex option will be needed.
You don't have to add Google Play Service Library in your codenameone app, just add android.includeGPlayServices=true to your build hint and it would be included in build server.

git ignore folder changes but still sync

I am working on an Android project that I sync with git. I imported Google and Facebook Sdks. I want the push to push the sdks so that they are shared, but not to track all the changes in the cache and such. Is there any way to do this?
Thanks
You need a .gitignore. You can add any number of rules to this file specifying files that git should ignore completely.
https://help.github.com/articles/ignoring-files

Categories

Resources