What happened last week: 03

A regular android developer log

Firebase

  • You can’t use the same application id (package name) and sha1 in different projects for Firebase. The main reason is oAuth. More details here. Just a quick summary of the details, you only need sha1 for Invites/Dynamic Links and Authentication features.
  • You can delete any application in your Firebase project now.
  • You have a limit to create projects in Firebase for free tier and deleting a project also takes time, 7 days. Therefore be careful.
  • You can use Firebase RemoteConfig in order to provide force update for your application. This feature is super useful for global dynamic key-value pairs.

Logging

Timber.plant(new Timber.DebugTree() {
@Override protected void log(...) {
Logger.log(priority, tag, message, t);
}
});
  • We added git hash and build time for Crashlytics logs. You can find the details in the link above. Instead of putting them into different build types, you can just put the build config fields inside defaultConfig block , it won’t harm to have the actual data for other build types.
Fabric.with(this, new Crashlytics());
Crashlytics.setString("GIT_SHA", BuildConfig.GIT_SHA);
Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);

Others

  • Here is a good article about strings.xml. Localization seems easy to everyone, since you only change a text or add another strings.xml file with another language. But to be honest, the time you spend for this manual work is quite a lot. There are a lot of back and forth decisions. We have the same issue and we tried a couple of things and and decide to automate this process. More info will be coming soon…
  • Use ContextCompact.getColor() instead of Context.getColor() for compatibility reasons. Usually it’s highlighted but somehow it is not highlighted in FirebaseMessagingService etc. Probably due to missing source.
  • Had a discussion about how play store actually nominates featured apps. There were a couple of ideas since there is no certain checklist for this or at least I couldn’t find. Material design, supporting latest api, tablet support and maybe accessibility. But most importantly someone actually has to contact a person from Google…
  • We moved from Travis to in-house Jenkins solution. Company was already using Jenkins and we find it more easy to configure and use. It’s also good for running UI Tests, nightly builds and of course it is now way faster since some dependencies are already downloaded. I also like that there are many plugins for your needs.
  • If you want to send a push notification from GCM/FCM in terminal, use the following command. Believe me sooner or later you will need this.
curl 
-s "https://android.googleapis.com/gcm/send"
-H "Authorization: key=[SERVER_API_KEY]"
-H "Content-Type: application/json"
-d '{"to": "[REG_TOKEN_HERE]", "data": {"key": "value"}}'
  • We use Fabric Beta for QA. Any merge to master creates staging and release versions and upload both of them to Fabric Beta. But there was always “play store upload” friction. And finally we added play store API to our CI. Any merge to master also uploads a release version to alpha channel in play store now. Annoying friction is removed. Here is a good guide for play store api integration. Note: We use the jenkins integration.

Git

First of all, Atlassian git tutorial is the best tutorial so far in my opinion. Super clear and easy to understand.

  • Since git 1.8.4, you can use “@” instead of “HEAD”. If you don’t know what is head, here is a good discussion.
  • rev-parse can be used for manipulation
// Last HEAD commit sha1
$ git rev-parse HEAD
// Previous HEAD commit sha1
$ git rev-parse HEAD~
// Total commit count
$ git rev-list --count HEAD
// One line representation for the history
$ git log --oneline
// One line with branch or tag info
$ git log --oneline --decorator
// Last 2 commits
$ git log -2
// Show all commits by range
$ git log <since>..<until>
// Prevent to display merge commits
$ git log --no-merges
  • We use git commit count number for android version number. If you are using github and if you always use rebase strategy instead of merge, you can use the merge count, that will be more convenient.
$ git rev-list --count --merges HEAD
  • Get all commit messages between the last and previous merge excluding merge commit messages. This is useful to get all commits for the last github pull request merge. We use this for Fabric Beta release notes.
$ git log @~.. --oneline --no-merges --pretty=%B

Gradle build has 3 phases:

  • Initialization phase: Gradle determines which projects are going to be involved. Usually determined by the settings.gradle file.
  • Configuration phase: Project objects are created along with build scripts executions. This is evaluation part. For example: “afterEvaluation” happens exactly at the end of this configuration phase and before the execution phase.
  • Execution phase: Gradle determines which sub tasks are going to be executed and start executing the tasks.

For more info about gradle build phases and lifecycle

Like what you read? Give Orhan Obut a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.