Version 10.0.0 of the Google Play services client libraries, as well as the Firebase client libraries for Android, will be the last version of these libraries that support Android API level 9 (Android 2.3, Gingerbread). The next scheduled release of these libraries, version 10.2.0, will increase the minimum supported API level from 9 to 14 (Android 4.0.1, Ice Cream Sandwich). This change will happen in early 2017.
The Gingerbread platform is almost six years old. Many Android developers have already discontinued support for Gingerbread in their apps. This helps them build better apps that make use of the newer capabilities of the Android platform. For us, the situation is the same. By making this change, we will be able to provide a more robust collection of tools for Android developers with greater speed.
You may use version 10.0.0 of Google Play services and Firebase as you are currently. It will continue to work with Gingerbread devices as it has in the past.
When you choose to upgrade to the future version 10.2.0, and if your app minimally supports API level 14 or greater (typically specified as "minSdkVersion" in your build.gradle), you will not encounter any versioning problems. However, if your app supports lower than API level 14, you will encounter a problem at build time with an error that looks like this:
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.google.android.gms:play-services:10.2.0] Suggestion: use tools:overrideLibrary="com.google.android.gms:play_services" to force usage
Unfortunately, the stated suggestion will not help you successfully run your app on older devices. In order to use Google Play services 10.2.0 and later, you can choose one of the following options:
This is the recommended course of action. To discontinue support for API levels that will no longer receive Google Play services updates, simply increase the minSdkVersion value in your app's build.gradle to at least 14. If you update your app in this way and publish it to the Play Store, users of devices with less than that level of support will not be able to see or download the update. However, they will still be able to download and use the most recently published version of the app that does target their device.
A very small percentage of all Android devices are using API levels less than 14. You can read more about the current distribution of Android devices. We believe that many of these old devices are not actively being used.
If your app still has a significant number of users on older devices, you can use multiple APK support in Google Play to deliver an APK that uses Google Play services 10.0.0. This is described below.
Along with some configuration and code management, you can build multiple APKs that support different minimum API levels, with different versions of Google Play services. You can accomplish this with build variants in Gradle. First, define build flavors for legacy and newer versions of your app. For example, in your build.gradle, define two different product flavors, with two different compile dependencies for the components of Play Services you're using:
productFlavors { legacy { minSdkVersion 9 versionCode 901 // Min API level 9, v01 } current { minSdkVersion 14 versionCode 1401 // Min API level 14, v01 } } dependencies { legacyCompile 'com.google.android.gms:play-services:10.0.0' currentCompile 'com.google.android.gms:play-services:10.2.0' }
In the above situation, there are two product flavors being built against two different versions of the Google Play services client libraries. This will work fine if only APIs are called that are available in the 10.0.0 library. If you need to call newer APIs made available with 10.2.0, you will have to create a compatibility library for the newer API calls so that they are only built into the version of the application that can use them:
After building a release APK for each flavor, you then publish them both to the Play Store, and the device will update with the most appropriate version for that device. Read more about multiple APK support in the Play Store.
Developer feedback continues to be a critical medium for us to ensure Firebase meets the needs of the community. Since we launched the expansion of Firebase at Google I/O in May, we received a clear message that many of you would like to try Firebase Test Lab without having to enter a credit card number and upgrade to the paid Blaze plan. We agree, and we're proud to introduce Firebase Test Lab for Android for the Firebase Spark and Flame plans. Here's how it works.
For Firebase projects on the Spark or Flame plan, you may run up to five tests on physical devices and up to ten tests on virtual devices on a daily basis. This means you have a total budget of fifteen tests to use throughout the day. For each test run, you may target up to four different devices, and you can mix physical and virtual devices as needed. For example, you could execute five runs targeting three devices each run, using your full budget of fifteen tests for the day. Or, each of your fifteen tests could be executed on a single device in fifteen individual runs.
For projects on the Spark plan, there is no billing information required to make use of your daily quota of tests.
For both plans, the daily quota of physical and virtual device tests refreshes at 12am PST, so you can use that to schedule your daily allotment of tests. The maximum duration for tests on virtual devices is one hour, and the maximum on physical devices is thirty minutes. You can also split your allotment of tests between Robo tests, which will test your application automatically, and instrumentation tests, which allow you to script your application with Espresso, UI Automator 2.0, and Robotium.
For projects on the Blaze plan, nothing changes. You continue to run tests for $5 per device-hour on physical devices. Virtual devices can be used at no cost till the end of December (12/31/2016) then at $1 per device-hour starting 2017.
Also available now is the ability to run tests against virtual devices with Nougat MR1 at API level 25. The Firebase Test Lab team is committed to making sure you have access to the latest versions of Android, so you can spot incompatibilities early during your development.
Improving the quality of your applications is easier with Firebase. Please let us know how you're using Firebase Test Lab for Android on our support channels, including the firebase-talk mailing list, and the #test-lab channel on the Firebase Slack.
Did you know that Firebase contains a whole bunch of features that makes it easier for you as a developer to build awesome apps?
Yeah, okay. That's probably not news.
But you might have noticed that, for a while, we've been talking about "apps" instead of "games". And that's because our mobile libraries work great... as long as you're writing your apps in Swift, Java, or Objective-C.
The problem is that most game developers are either building their own game engines in C++ or using popular 3rd party game platforms like Cocos2D or Unity to power their mobile games. And while we've had a C++ version of the Firebase library available in beta for a while now, our Unity developers have been left with a rather out-of-date Firebase Database plugin...
...until now! Thanks to a lot of hard work from a lot of our engineers and your continued feedback, there's a brand new, officially supported, Unity SDK that includes a whole lot more of the Firebase platform.
So what does this offering mean for you as a Unity developer? It means you can now take advantage of many of the new Firebase features that we announced back in May. Including...
Firebase Analytics: A free and unlimited analytics package to record events that happen within your game. Find out where in your game players are getting stuck, how your audience is growing over time, or where players from each different country are spending their premium currency. All of this is easy to record with Firebase Analytics, and its integration with BigQuery allows you to run some pretty sophisticated data mining along the way.
The Firebase Real-time Database: This is a database where your app's data magically syncs across all devices, usually within a few hundred milliseconds. It's great for near-real-time features like in-game chat, syncing your user's saved game across devices, or potentially powering a turn-based board, card, or strategy game. That said, you probably don't want to use it to drive your multiplayer shooter or MOBA -- I know with game developers, we need to a little more explicit about what 'real-time' actually means. ;)
Dynamic Links. These are mobile deep links that you can use to point players to any element of your game (if they have it installed), or take them to the Play Store / App Store (if they don't). I think the best use case here for game developers would be to use Dynamic Links to help power in-app sharing. You can use Dynamic Links to share a replay of a level, or a link to your player's awesome new character / fortress / user-generated content. And if you don't feel like building our your own interface to do all of this, Firebase Invites can create one for you, by packaging up a Dynamic Link inside a nicely formatted email or SMS message.
Authentication: "Boy, I really like spending all my time building authentication systems instead of working on my game," said no game developer ever. With Firebase Auth, we make it easier for you to sign in your users in from third party providers like Facebook, Google, and Github, or to create a custom username and password system.
Cloud Messaging: Firebase Cloud Messaging allows you to send notifications to both iOS and Android devices through a single endpoint. It also lets you send notifications through the Firebase Notifications panel, which means non-technical members of your team can send notifications without your having to worry about writing any custom server code or curl calls.
Remote Config: This feature lets you update your game's values from the cloud. Honestly, this is the feature I'm most excited about for games. Anybody who's designed a tower defense game knows that one overpowered stat in a single unit can throw off the balance of your entire game. With Remote Config you can tweak those values from the cloud, and then use Firebase Analytics to see if they give you the results you expect. You can even use Remote Config to deliver custom values to specific groups of people, like your expert players.
You can use this library with Android and iOS devices, but the team has nicely added in stub methods for Windows, OSX, and Linux, so you don't need to worry about adding a bunch of conditional code if your game is also targeting desktops. As a side note, the Real-time Database part of the SDK works directly within the Unity editor, which makes testing and debugging a bit nicer.
We encourage you to give the Firebase SDK for Unity a try! It's available right here, and it contains a whole bunch of features that makes it easier for you as a developer to build some pretty awesome… games.
Yeah, that felt good to write.
Nowadays, many users prefer using federated login, such as Google Sign-In, Facebook, Twitter and others, over having to create a new account for every service they use. Each user has their own favorite federated login provider, and it would take a lot of effort to integrate and manage each federated login provider for your app. This is where Firebase Authentication can help.
Firebase Authentication supports many popular federated login providers. You just need to integrate with Firebase Authentication, and let Firebase automatically manage multiple federated login providers under the hood for you.
However, depending on where your users are in the world, they may prefer a federated login providers for which Firebase does not have built-in support yet. For example, in Japan and many Asian countries, LINE Login is very popular with hundreds of millions of users, so you may want to support it as well. Fortunately, it is fairly simple to integrate LINE Login, as well as many other federated login, with Firebase Authentication using Custom Auth.
In one of our previous blog post, we have shown how to support federated login that was not available out-of-the-box with Firebase Authentication on the web using our JavaScript SDK. In this blog post, I will show you how to integrate with LINE Login on iOS and Android.
Here is how the login flow looks like:
Step 1: Use LINE Login SDK to log user in, and acquire their LINE Access Token
Step 2: Send their LINE Access Token to your server and validate it with LINE authentication server. If the token is valid, then create a Firebase Custom Auth token correspond to the user, and send it back to user's device.
Step 3: Use the Firebase Custom Auth token to login to Firebase from the device.
You will need to do some setup work to get your LINE business account and Firebase project ready.
Refer to LINE Login document (iOS / Android) to integrate LINE SDK to your app and implement LINE Login flow. Once user has successfully logged in, you can get their LINE access token as below:
iOS (Objective-C)
NSString *lineAccessToken = self.lineAdapter.getLineApiClient.accessToken;
Android
LineAuthManager authManager = LineSdkContextManager.getSdkContext().getAuthManager(); final String accessToken = authManager.getAccessToken().accessToken;
Then you can use your favorite networking library to send the access token to your own server for validation. In this sample code, I use GTM HTTP Fetcher for iOS and Volley for Android.
NSURL *url = [NSURL URLWithString:@"https:///verifyToken"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"content-type"]; NSDictionary *token = @{@"token" : lineAccessToken}; NSError *error; NSData *requestBody = [NSJSONSerialization dataWithJSONObject:token options:kNilOptions error:&error]; [request setHTTPBody:requestBody]; GTMHTTPFetcher *fetcher = [GTMHTTPFetcher fetcherWithRequest:request]; [fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) { if (!error) { // Extract Firebase Custom Auth token from response // ・・・ } }];
HashMap validationObject = new HashMap<>(); validationObject.put("token", accessToken); Response.Listener responseListener = new Response.Listener() { @Override public void onResponse(JSONObject response) { // Extract Firebase Custom Auth token from response // ・・・ } }; JsonObjectRequest fbTokenRequest = new JsonObjectRequest( Request.Method.POST, "https:///verifyToken", new JSONObject(validationObject), responseListener, errorListener); NetworkSingleton.getInstance(activity).addToRequestQueue(fbTokenRequest);
You will need a server to validate LINE access token and generate a corresponding Firebase Custom Auth token for that user. You can build a simple one with Firebase Node.js Server SDK and Express web server.
Firstly, your server receives the LINE Access Token from user's device and validates it using LINE Social Rest API. Don't forget to verify the channelId value in API response to make sure that the access token is actually issued for your app. This is to prevent spoof attack, of which attackers reuse access token from other app/channel to attempt login to your app.
Server (Node.js)
app.post('/verifyToken', (req, res) => { if (!req.body.token) { return res.status(400).send('Access Token not found'); } const reqToken = req.body.token; // Send request to LINE server for access token verification const options = { url: 'https://api.line.me/v1/oauth/verify', headers: { 'Authorization': `Bearer ${reqToken}` } }; request(options, (error, response, body) => { if (!error && response.statusCode === 200) { const lineObj = JSON.parse(body); // Don't forget to verify the token's channelId to prevent spoof attack if ((typeof lineObj.mid !== 'undefined') && (lineObj.channelId === myLINEChannelId)) { // Access Token Validation succeed with LINE server // Generate Firebase token and return to device const firebaseToken = generateFirebaseToken(lineObj.mid); // Update Firebase user profile with LINE profile updateUserProfile(reqToken, firebaseToken, lineObj.mid, () => { const ret = { firebase_token: firebaseToken }; return res.status(200).send(ret); }); } } const ret = { error_message: 'Authentication error: Cannot verify access token.' }; return res.status(403).send(ret); }); } });
After successfully validated LINE Access Token, use Firebase Server SDK to generate Firebase Custom Auth token and return it to the user device. You can reuse LINE's user ID for your Firebase user ID.
function generateFirebaseToken(lineMid) { var firebaseUid = 'line:' + lineMid; var additionalClaims = { provider: 'LINE' }; return firebase.auth().createCustomToken(firebaseUid); }
We also have a Firebase Server Java SDK.
You can make use of solutions like App Engine Flexible Environment or Cloud Functions to free yourself from managing the server.
After receiving the Firebase Custom Auth token, just use it to sign the user in Firebase:
[[FIRAuth auth] signInWithCustomToken:firebaseToken completion:^(FIRUser * _Nullable user, NSError * _Nullable error) { // Process sign in result // ・・・ }];
FirebaseAuth.getInstance() .signInWithCustomToken(firebaseToken) .addOnCompleteListener(new OnCompleteListener() { // Process sign in result // ・・・ });
Our sample code is open source. Feel free to download and give it a try. https://github.com/firebase/custom-auth-samples/tree/master/Line
Earlier this year, we introduced the expansion of Firebase: a unified app platform that provides developers a variety of tools and a scalable infrastructure to build high quality apps and grow successful businesses across Android, iOS and the Web. This blog post is not about the 'what' but more about the 'how'. How do you implement Firebase into your app quickly and easily?
Today we are launching a complete end-to-end video training course called "Firebase in a Weekend". Whether you develop Android or iOS apps, the training course helps you understand many of the core features of Firebase, learned by building an app from the ground up.
Join some of our favorite Firebase instructors as they walk you through building a functioning messaging app using:
We partnered with Udacity, the online learning platform, to give you a more personalized, in depth explanation of Firebase and its features. You can learn how to do it on either Android or iOS by watching short videos enhanced with code samples and assessments.
Check out the Android or iOS course online for no charge. Check out all of the courses at udacity.com/google.