Once you have created your project, there are two ways to run that. The first one is creating an Android Virtual Device (AVD) on your computer. And the second one is running on your smartphone. I think the most of people will prefer to follow the second way. So let’s see how to do that now.
1 Enable developer settings on your phone
To enable developer settings, you should find the Build number in your phone. In mine, I found this info in Settings→ About phone. Touch a few times on Build number and a message will be shown. Go back and will see a new setting: Developer options. There you can activate USB debugging, mock locations etc.
2 Install the phone driver
Each phone has your own driver. And it shouldn’t be difficult to find that on Google. If you have a Sony Xperia T2 Ultra, for example, you can download the driver here. And to install that on Windows, unzip the package, and follow this path: Device Manager→ Action→ Add Legacy hardware→ Advanced→ Show All Devices→ Have Disk…→ Browse…→ Xperia_T2_Ultra_driver directory→ sa0110adb file→ OK→ Finish.
3 Connect your phone
Using an USB cable, connect the phone to computer.
4 Make Android Studio recognize your device
To do that, first I accessed Android Studio→Run→ Edit Configurations→ app→ General→ Target and choose USB Device. But for a mysterious reason it didn’t work. The device was not found and I couldn’t run the app at that moment. After some time looking for an answer on Stack Overflow, I changed the target to Open Select Deployment Target Dialog (instead of USB Device) and for a very very mysterious reason it works. Finally the phone was recognized.
5 Run your app
Click on Run button and your phone will ask if you allow USB debugging. Why not? And now you are seeing your first app running. Congratulations!
The app is now installed on your phone and you can use that always you need to see a "Hello World!" message. It's certainly very useful but we still can improve that, right? On the next post!