Last Six Months Programming With Github Copilot As An Android Developer
Before using GitHub Copilot I have started AI pair development with ChatGPT. Even though I have three monitors, switching monitors was not fun because I am the kind of person who wants to fully focus the screen when the IDE is opened. Then I started to look for Android Studio plugins that can improve my productivity to embed ChatGPT or other AI products.
Then I encountered Github Copilot and found it was worth a try. They offer a 30-day trial. Also if you are suitable for one of the following criteria you can use it free.
GitHub Copilot is free to use for verified students, teachers, and maintainers of popular open source projects. If you are not a student, teacher, or maintainer of a popular open source project, you can try GitHub Copilot for free with a one-time 30-day trial.
Anyways here are what I learnt to use Github Copilot better
How to Install Github Copilot
To use GitHub Copilot in AndroidStudio you must install Copilot extension.
Click the settings from menu then find the Plugins section. Click Marketplace. In the search bar, search for GitHub Copilot, then click Install.
After GitHub Copilot is installed restart AndroidStudio.
After your AndroidStudio has restarted, click the Tools menu. Click GitHub Copilot, then click Login to GitHub.
In the “Sign in to GitHub” dialog box, and copy device activation code and open browser with this action. Then paste activation code to activation window in browser. GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize GitHub Copilot Plugin.
To Get More Meaningful Suggestion Make Your Code And Resources More Predictable
Using patterns in your codes helps AI to predict more accurately and this also makes your code cleaner. As the following example, instance name and string have patterns to make code more predictable. Otherwise, AI would suggest random meaningful string resources which may not expected.
To Get More Meaningful Suggestion Talk AI Over Comments
Let’s say we want to check app update status and AI recommend a function that is just nothing but returns false.
In these kinds of functions, we should refer to use cases as comments. Also, it will help other developers understand how the function works.
Copilot will encourage the simplest solution as much as possible but the simplest does not mean a working solution so we can help it to select which way it should continue. After guiding it will complete a function as expected but you should all time review the code is written by AI because it may finish similar to right solution, but it might not be
We can take this part as prompt engineering.
All Suggestions Will Not Be Best Solution
Copilot helps us to find the most popular code completion from the git repos, but it does not mean the right or best solution. For example, the following example copilot suggested that I create html-supported text with android.text.Html.FROM_HTML_MODE_LEGACY flag.
I do not go into details about my project but the android project that supports Android API 24 or higher so using android.text.Html.FROM_HTML_MODE_COMPACT is going to make more sense. That shows Copilot may not suggest you project target build or something similar dependencies. Reviewing process is still vital.
To Sum Up
I started a project with CoPilot and it is open. It seems creating your code and resources suggestible and sustainable patterns help CoPilot’s understanding and suggesting algorithm. Also, it helps a developer too. I like this kind of encouragement.
Sometimes it makes vital suggestions but if you review the code that is not a big deal you can easily get the next suggestion, you can give a good prompt over comment or you can make a starting point of function to help it.
I handed my workload about %30 percent. When I see the plugin is not opened and not making suggestions due to the IDE plugin bug issue, I do not continue before reopening IDE that shows it helps me.