Setting up a git repository for android studio projects
###Creating the Project
- Open up Android Studio
- New Project...
- Application Name: Anything you want. ExampleApp for example.
- Module name: Anything you want. App is default for single module projects
- Package Name: Generally com.[company name].[project name].[module]
- Project Location: Default is fine (auto-generated from above information)
- Minimum required SDK: API15 is good (API15 and up cover most users and give a nice set of features)
- Target SDK: Up to you. Latest and greatest is nice.
- Compile With: Latest and greatest all the way.
- Language Level: Default is fine
- Theme: You can explore these later but they're just the appearance theme of the app. Default is fine. You can change it later.
- Create activity (you need this if you're going to be running this application - though you can do it manually if you wish)
- Next ->
- Blank Activity is fine for now.
- Keep going Next -> Until it starts building stuff.
- Leave it for now.
###Creating the Github Repo
- Create a new repository
- Name it whatever you want
- Give it a description
- Initialize with README
###Project initialization in github repository
- Terminal > Go to your local top-level project folder
- git init
- git remote add origin [github repo HTTPS clone url]
- Add .idea/ to .gitignore
- Add *.iml to .gitignore
- git add .gitignore && git commit -m "ADD: gitignore" && git pull --rebase origin master
- git push -u origin master
- git add . # or git add -A
- git commit -m "android studio project initialization" # Or whatever you want your message to be. these are important.
- git push -u origin master
###Importing the project from a git repository If you're getting someone else's code or sharing this project via git, you must import the project when opening it for the first time.
- git clone [Github Repo HTTPS clone url]
- Open Android Studio
- Import Project ...
- Navigate to the right directory
- Select on the build.gradle in the top-level directory
- And go!
- This sets up the local configurations files for you based on gradle and the project structure. (the things we gitignored)
- Remember your Gitiquette (Git Etiquette)
- Add files individually based on what feature you worked on / changed
- Commit them with useful messages detailing what you did for reference
- Make use of git status as much as you can to make sure you know what git things are going on
- Make use of separate branches for major changes. git checkout -b [new branch for new feature]. Make pull-requests back to master after testing.
- Always test your application to make sure everything works before you push a new change (or you'll have a shitty time later).
- Master branch should ALWAYS be functional. If you break master, you're in for a lot of pain by your collaborators. (people branch off of master to make changes. it should always work!)
- If you have questions about git, ask right away before you break things.
We will be going over the pseudo-model-view-controller framework for Android on the first day of class. You'll need to understand how that works.
- Take a look at your res (resources) folder. It contains the XMLs you will be using to provide content and layout to the app.
- Take a look at your src (source) folder. It contains the java classes that take care of the logic behind the app.
- Make sure you understand how "hello world" is being displayed in the generated code.
- Add an OnClick functionality to the "hello world" text.
- Add an ActionBar menu button that updates UI Elements in some way.
- Once you're done, take a look at this repository's app. (git clone and android import build.gradle)
- This code has basic structure of what the app should look like as well as comments for what lines of code do. It also demonstrates a standard oragnization of code. It will save you lots of pain if you follow some organization in coding Android apps (Java in general). Files will grow disgustingly long and chaotic otherwise.