OpenAI Android developer assistance
Hello budding prompt engineers,
Many developers are already getting assistance from GitHub Copilot completing code and more recently the conversational additions to GitHub pull requests, documentation, and the CLI. In this post we’ll look at some of the ways that Android developers can take advantage of OpenAI- and ChatGPT-powered tools.
GitHub Copilot in Android Studio
GitHub Copilot can be added to Android Studio as a plugin – from the Settings/Preferences screen go to Plugins, search for “copilot” and choose Install:
Figure 1: GitHub Copilot in the Plugin Marketplace
Once installed (and Android Studio restarted) there will be a GitHub Copilot tool window to show suggestions as well as autocompletions as you type (if enabled):
Figure 2: GitHub Copilot suggestions in Android Studio
In Figure 2 copilot is suggesting Jetpack Window Manager boilerplate in our SourceEditor sample. In addition to the solutions tool window, you can trigger inline suggestions with Alt+\ and toggle between suggestions with Alt+[ and Alt+] (on macOS use the Option ⌥ key).
Installing the plugin will also add a settings screen under Languages & Frameworks where you can enable or disable completions globally or for specific programming languages.
Outside of the IDE, ChatGPT can also answer coding questions and much more, directly in the browser. For example, in Figure 3 the prompt asks about the “parameterized strings” feature, and ChatGPT answers with both an explanation and code examples:
Figure 3: ChatGPT answering a coding question
For more prompt ideas, this ChatGPT post has some great examples of generating Kotlin code, finding bugs, writing tests, writing documentation, and explaining concepts.
Help with localization
Machine translation is never perfect and it’s always preferable to have bilingual speakers review localization of your apps. However, testing your app in other languages for layout correctness, and making sure you haven’t missed any strings, can be useful – even with imperfect translations. This is another area where ChatGPT can simplify a previously tedious process – because it can understand XML (and other) file formats and what should be translated versus preserved,
The resulting XML can then be included in appropriately named values-fr/strings.xml and values-de/strings.xml (French and German) resource files. This example is from our SourceEditor sample app.
As with any machine processed output, you should verify everything before using it in a public release.
Resources and feedback
You can sign up for OpenAI at https://openai.com/ to start querying all your code questions.
GitHub Copilot X has a preview sign-up form to test the pull-request improvements and other new features.
If you have any questions about applying AI to your development tools, use the feedback forum or message us on Twitter @surfaceduodev.
We won’t be livestreaming this week, but check out the archives on YouTube and we’ll see you online again soon!