Wednesday, June 26, 2013

Adding a Backend to Your App In Android Studio

Posted by Sachin Kotwani, Google Cloud Platform team

Android Studio lets you easily add a cloud backend to your application, right from your IDE. A backend allows you to implement functionality such as backing up user data to the cloud, serving content to client apps, real-time interactions, sending push notifications through Google Cloud Messaging for Android (GCM), and more. Additionally, having your application�s backend hosted on Google App Engine means that you can focus on what the cloud application does, without having to worry about administration, reliability or scalability.



When you create a backend using Android Studio, it generates a new App Engine application under the same project, and gives your Android application the necessary libraries and a sample activity to interact with that backend. Support for GCM is built-in, making it easy to sync data across multiple devices. Once you've generated the project, you can build and run your client and server code together, in a single environment, and even deploy your backend code right from Android Studio.



In this post we�ll focus on how to get started with the basic setup. From there it's easy to extend the basic setup to meet your needs.









Preliminary setup



Before you get started, make sure you take care of these tasks first:



  • Download Android Studio if you haven�t done so already and set it up.

  • Make sure you have an application project set up in Android Studio. You can use any working app that you want to integrate with your backend, even a sample app.

  • If you'll be running the app on an emulator, download the Google APIs Addon from the SDK Manager and run your app on that image.



  • Create a Google Cloud Platform project: In the Cloud Console, create a new project (or reuse an old one) and make note of the Project ID. Click on the words �Project ID� on the top left to toggle to the Project Number. Copy this as well.

  • Enable GCM and obtain API Key: In the Cloud Console, click on APIs and turn on the Google Cloud Messaging for Android API. Then, click on the �Register App� button on the top left, enter a name for the app, then select �Android� and �Accessing APIs via a web server�. In the resulting screen, expand the �Server Key� box and copy the API key.




1. Generate an App Engine project



In Android Studio, open an existing Android application that you want to modify, or create a new one. Select the Android app module under the Project node. Then click Tools > Google Cloud Endpoints > Create App Engine Backend.



In the wizard, enter the Project ID, Project Number, and API Key of your Cloud project.





This will create:



  • An App Engine project which contains the backend application source

  • An endpoints module with a RegisterActivity class, related resources, and client libraries for the Android app to communicate with the backend



The generated App Engine application (<app_name>-AppEngine) is an Apache Maven-based project. The Maven pom.xml file takes care of downloading all the dependencies, including the App Engine SDK. This module also contains the following:



  • A Google Cloud Endpoint (DeviceInfoEndpoint.java, auto-generated from DeviceInfo.java) that your Android app will �register� itself through. Your backend will use that registration info to send a push notification to the device.

  • A sample endpoint, MessageEndpoint.java, to list previously sent GCM messages and send new ones.

  • A starter web frontend application (index.html in webapp directory) that will show all the devices that have registered with your service, and a form to send them a GCM notification.



The endpoints module (<app_name>-endpoints) generated for you contains the classes and libraries needed by the Android application to interact with the backend:



  • A RegisterActivity.java class that, when invoked, will go through the GCM registration flow and also register itself with the recently created backend through DeviceInfoEndpoint.

  • Client libraries, so that the application can talk to the backend using an object rather than directly using raw REST calls.

  • XML files related to the newly created activity.



2. Add GCM registration to your app



In your Android application, you can call RegisterActivity whenever you want the registration to take place (for example, from within the onCreate() method of your main activity.



...
import android.content.Intent;
...

@Override
protected void onCreate(Bundle savedInstanceState) {
...
Intent intent = new Intent(this, RegisterActivity.class);
startActivity(intent);
}



3. Deploy the sample backend server



When you're ready to deploy an update to your ( the sample ) production backend in the cloud, you can do that easily from the IDE. Click on the �Maven Projects� button on the right edge of the IDE, under Plugins > App Engine, right-click and run the appengine:update goal.





As soon as the update is deployed, you can also access your endpoints through the APIs Explorer at http://<project-id>.appspot.com/_ah/api/explorer.






For testing and debugging, you can also run your backend server locally without having to deploy your changes to the production backend. To run the backend locally, just set the value of LOCAL_ANDROID_RUN to true in CloudEndpointUtils.java in the App Engine module.



4. Build and run the Android app



Now build and run your Android app. If you called RegisterActivity from within your main activity, the device will register itself with the GCM service and the App Engine app you just deployed. If you are running the app on an emulator, note that GCM functionality requires the Google APIs Addon image, which you can download from the SDK Manager.



You can access your sample web console on any browser at http://<project-id>.appspot.com. There, you will see that the app you just started has registered with the backend. Fill out the form and send a message to see GCM in action!



Extending the basic setup



It's easy to expand your cloud services right in Android Studio. You can add new server-side code and through Android Studio instantly generate your own custom endpoints to access those services from your Android app.



Monday, June 24, 2013

Offer Your Educational Apps On Google Play for Education

Posted by Pratip Banerji, Google Play for Education team




Last month, we announced Google Play for Education — a platform enabling developers and content providers to reach K-12 educators and students in the United States through a new Android based initiative. Google Play for Education is an extension of the Google Play Store for schools, adding curation, bulk purchasing, and instant distribution to students� Android tablets for educational apps, books and videos. As we said at the time, we are excited to be doing our part to make technology and innovation in the classroom more accessible.



Starting today, you can use the Google Play Developer Console to mark your apps for inclusion in Google Play for Education, which is actively being piloted in schools across the country. Marking your app identifies it as targeted for the US K-12 educational market and queues it for evaluation by a third-party network of educators. These educators perform a first-pass qualification of apps, assigning the appropriate subject, grade, and common core standards metadata, while evaluating whether they meet the Google Play for Education criteria for classroom use.



Leading up to the fall launch, the Google Play for Education team is conducting an extensive series of pilots that include schools and students across the U.S. By marking your app for inclusion now, you will be getting your app into the hands of these schools and key influencers in the education technology community.



Whether you already have an existing educational app or are looking to build one, take a look at our Guidelines for Apps to make sure your app is appropriate for the K-12 environment. Follow our detailed requirements and test your app to ensure it is optimized for Android tablets. Then, upload your new or updated app, mark it for inclusion in Google Play for Education, and publish. We will email you when your app has been evaluated. Depending on app submission volume, this process can take 3-4 weeks. For more information, see Get Started.



Also please tune in to our panel for education developers on Tuesday June 25th at 10:30 AM EDT. Live from the ISTE (the International Society for Technology in Education) Conference, we�ll tell you more about developing for Google in Education and we�ll host some educators who explain what they are looking for in educational apps. The panel will be streamed on Google Developers Live and we'll make the video available to you as well.



For more information on Google Play for Education, please visit developer.android.com/edu.

Thursday, June 6, 2013

Google Play Developer 8-Step Checkup

checkup_droid


Posted by Ellie Powers, Google Play team



Google Play gives you tons of options on publishing your apps and connecting with users. But as you get started with new features like beta testing and staged rollouts, it�s a good idea to do a checkup and make sure you�ve covered the basics.



1. Boost your developer account security



  • If you take just one step today to protect your Google Play apps, enable two-step authentication for your Google account, and encourage the rest of your team to do the same.

  • Next, many developers first set up their Google Play account with their personal gmail account, but it�s actually a good idea to transfer your apps to a separate account. All of your installations and reviews remain intact. If you haven�t done this already, transfer your apps to a new account today.

  • Don�t share passwords. Instead, add each individual who needs access and only grant the minimum level of access they need — and encourage them to enable two-step authentication.

  • Review the list of people with access regularly, and when people leave your project, make it a standard practice to remove their access. Learn more about developer account security.



2. Protect your keystore


In order to publish an update to an existing app, you�ll need to sign it with the same keystore every time. If you lose your keystore, you�ll lose your history and reviews, so you�ll need to start over with new apps with new package name and a new key, so you�ll want to make sure you protect it. First, choose a secure password, and don�t use the same password that you use for your Google account. Next, back up your keystore somewhere, but don�t upload it to Google Drive with an account you use to publish on Google Play.



3. Check your email addresses


As a developer, you are responsible for checking two important email addresses:



  • Account owner email address: Google uses the address used to register your Developer Console to contact you about your apps and account, so it is extremely important that someone is responsible for checking it regularly. If necessary, you can forward messages from this account via Gmail, or transfer your apps to another account.

  • Customer support email address: For each individual application, you can specify the best way for users to contact you for customer support. Ensure that a valid support email address for your product is specified. As a best practice, this should probably be a designated support account that is checked regularly and not the same email as the address used to login to the Developer Console.



4. Familiarize yourself with the policies


We recently launched some new guides and examples for Google Play�s Developer Program Policies and Developer Distribution Agreement. Note that once you publish an app as free, you can�t change it to a paid app later, though you can add in-app products.



5. Set up team processes


You may have many people involved with your Google Play apps. Make sure roles are clear in terms of whose job it is to publish updates, check statistics and optimization tips, read and reply to user reviews, and track revenue. Make sure all of these people have the right access to the Developer Console. Many developers who are part of larger organizations also report to their larger teams about their apps� performance. Designate someone to make sure your app description, graphics (including localized and tablet screenshots), and pricing are up to date.



6. Configure your Developer Console UI languages


To change the language you want to see the Developer Console in, set your primary language. If you speak additional languages, configure those, too — user reviews in those languages won�t be translated automatically in the Developer Console. That was a popular request from developers.



7. Refresh your app�s marketing materials




8. Stay on top of developer news


To make sure you�re aware of the latest Google Play updates for developers, make sure you check the Android Developers blog regularly, follow +Android Developers, and check the Developer Console regularly for announcements.


Monday, June 3, 2013

Bootstrap Your App's Cloud Services with Mobile Backend Starter

Posted by Brad Abrams, Product Manager, Google Cloud Platform

Many of the best mobile app experiences are powered by services in the cloud. Top Android developers such as Pulse and SongPop have long taken advantage of the convenience and scalability of Google's cloud platform in their businesses. Now with the Mobile Backend Starter, it's even easier to add cloud services to your apps.



Mobile Backend Starter


Mobile Backend Starter is a one-click deployable, complete mobile backend that allows you to reap the benefits of a cloud backend with none of the headaches. It provides a ready-to-deploy, general purpose cloud backend and a general purpose client-side framework for Android.



Mobile Backend Starter gives you everything you need to rapidly set up a backend for your app, without needing to write any backend code. It includes a server that stores your data with App Engine and a client library and sample app for Android that make it easy to access that data. You can also add support for Google Cloud Messaging (GCM) and continuous queries that notify your app of events you are interested in. To keep user data secure, Mobile Backend Starter also includes built-in support for Google Authentication.





Features of Mobile Backend Starter include:




  • Cloud data storage: Users change devices and increasingly use multiple devices. Store any amount of data per user in the cloud to be accessed from anywhere.

  • Pub/Sub messaging: Send messages from one device, to any or all other devices. You can easily use 1:1 and 1:many messaging as well as broadcasting. This feature is useful for various applications including social apps, forums, chat, gaming, and group collaborations.

  • Push notifications: Data updated on one device is automatically available on all devices with GCM for Android.

  • Continuous queries: Create queries that run continuously on the server, automatically feeding updates to the client. These queries are powered by Prospective Search.

  • Google authentication and authorization: Keep data isolated per user or shared among users.

  • Free to get started, scales with your needs: You can start by handling hundreds of users for free, then grow to any scale.



Quick setup and integration



You can set up and run the Mobile Backend Starter in just few steps:




  1. First, go to the Google Cloud Console, and create a project. Then click Deploy.

  2. Click on Settings to go to the admin control panel for your new backend. Under Authentication / Authorization, select "Open (for development use only)" and save the changes.



  3. Next, download the Android client project and open it up in your Android IDE. Locate the Consts.java file and set the PROJECT_ID to the Project ID of the project you created in the Google Cloud Console.

  4. Now just build and run the Android application and you have a cloud enabled Android application.



Check out the complete docs for details on setup as well as information on how to enable authentication, send push notifications, and use standing queries.



The best part is you can download the complete source code of the backend on GitHub and customize it however you want to meet your needs.



See Mobile Backend Starter in action at Google I/O



To see Mobile Backend Starter in action, check out our talk at Google I/O 2013 (embedded below) called "From Nothing to Nirvana in Minutes: Cloud Backend for Your Android Application". The talk shows how to use Mobile Backend Starter to create a new backend server and integrate it with an Android app via Google Cloud Endpoints and the Google Plugin for Eclipse.



We look forward to hearing your questions and learning about the amazing applications you have built. You can find us lurking on the Cloud Endpoints StackOverflow forum.