Showing posts with label Android Studio Projects. Show all posts
Showing posts with label Android Studio Projects. Show all posts

Upload your projects from Android Studio to GitHub

Wikipedia defines GitHub as a web-based hosting service for version control using git. It is mostly used for computer code. It offers all of the distributed version control and source code management functionality of Git as well as adding its own features.
One of the advantages of uploading your projects on GitHub is that it helps to showcase your work to the world.

Steps you need to follow in order to upload your projects to GitHub from your Android studio.

1. If you don't have a Github account, you need to create one. Head up to https://github.com and create an account, it is fast and easy.

2. Download and install Git on your PC from https://git-scm.com/downloads. Launch Git Bash and enter the following lines
git config --global user.email "you@example.com". Replace you@example.com with your email. Click Enter on your keyboard
 git config --global user.name "Your Name". to set your account's default identity. Omit --global to set the identity only in this repository





3. Launch your Android Studio and open the project you want to export to GitHub.


4. Go to File >> Settings >> Version Control >> Git.


5. Click on the "test" button at the top right corner to test "Path to Git executable". If you get "Git executed successfully",  you are good to go otherwise navigate to the path where you Git is installed.



6. Go to File >> Settings >> Version Control >> GitHub. Enter your email in the login box and your password in the password box (Enter the email address and password of your GitHub account). Then Ok. A window appears, just leave it blank and click Ok.




7. Go to VCS >> Import into Version Control >> Share Project on GitHub. Enter the name of you want to name the repository, the description of the project, then, click on the '"share button".







8. A window will appear, you are to check all files in order to add files for initial commit. Then click Ok.

The project will be uploaded to the GitHub repository. If the uploading is successful, you see this message on the top right corner of your Android studio "Successfully shared project on GitHub". You can click on the link provided below the success message to go to your newly created repository.

Getting Familiar with Android Studio


Open a new project by clicking on Open a new project, follow the steps as shown in the below


Click on start a new Android Studio Project


Enter whatever name you want to name your project, Make your Project name start with an Uppercase e.g. BookApp, TextApp etc.


 Then click on Next


Just click on Next


Make sure you pick the Empty Activity for the purpose of this tutorial and click on Next.


Just click on Finish and wait for a while the gradle builds and your environment is ready for you to use.

For some people that don’t have internet access, you’ll need to work offline. In order to do so, go to  project > Android > Gradle Scripts > build.gradle (Module:app)



Note: There are two build.gradle files, build.gradle (Project:Language) and build.gradle(Module:app), you should select the second build.gradle. 
Then you’ll delete some lines of code in the build.gradle, the highlighted lines only. When you are done, you will click on Try Again at the top right side, as it is indicated below. You’ll wait while it finishing building.




Understanding your environment, Android Studio

I will explain some terminologies to you so that you will familiarize yourself with Android Studio. I know many of the names will be strange to you (if you are new to Android Studio and programming). I will explain the basic ones and as we progress, I will explain more.

  1.      AndroidManifest.xml is responsible for many things including the first activity that will be launched. To pick the activity that would be launched first, you need to go to AndroidManifest.xml. Your App Icon is set in AndroidManifest.xml. I will say AndroidManifest.xml determines how your codes will run on your phone. Any Activity you open and is not listed in the AndroidManifest.xml will not be accessible when you run your App on a mobile phone.
  2.  Java (e.g Details and MainActivity) is the java file where you will be writing all your java codes. If you open another java class, it will display here. As you can see, there are only two java classes.
  3.  res folder is the folder where all your resource files are located and stored. Resources like layout, images, strings, color etc. are stored under the resource folder directory.
  4. drawable is the folder responsible for storing images that you want to you in your project. When you want to use an image in your project, you copy the image from PC and paste it the drawable folder.
  5.  layout is where all your activities are stored. The activities that you interact with when you run App on your device.
  6. mipmap is where your default Android Icon is stored.
  7. colors.xml is where colors are stored.
  8. strings.xml is where strings are stored. Strings are literal in Android language. “I want to learning Android Programming” is an example of String.
  9. styles.xml is responsible for styling of your App, the color of your status bar, color of your toolbar, text background color, the theme of your App.


Running our App on a physical device like our Android Phone


Tools: An Android Phone and ADB Driver Installer you downloaded.

On your Android Phone, go to Settings > About phone > Build number.
Tap on Build number seven times, then a toast message will appear “You are now a developer”.
Then, press the back button, directly above “About phone”, you will see “Developer options”
Tap on it, enable it by clicking on the on switch. Scroll down and enable the USB debugging.

Connect your Android phone to your computer with a transferrable USB cord/wire.
Launch ADB Driver Installer. Your Android Phone will be displayed on where I highlighted and you will click on Install



So, when your Android phone is successfully installed, go to your Android Studio
Click on “Run” on the menu bar, click on “Run app” on the drop down menu. A box pops up


If your Phone was not successfully installed, it won’t appear, it will bring “No USB devices or running emulators detected”. In case your phone was successfully installed, check your USB cord/ wire.
Click on OK
Click on Proceed without instant run.
Congratulations your just created your first mobile App


Working with Emulator

In case you don’t have an Android phone to debug your App with. Android Studio provides with a tool called Emulator you can use.
An emulator looks an Android mobile, it just that you can touch and feel it. It runs like an Android phone. It is a cool tool. I won’t really advice it and I am not kicking against either. It makes System hangs especially systems with low memory.
Check this link to get started with emulator https://developer.android.com/studio/run/emulator.html

If you have any issues using it, drop your comments and I will help you out.