Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 3.07 KB

10-1-M-Create-Android-Project.adoc

File metadata and controls

77 lines (61 loc) · 3.07 KB

Setting up your repository

  1. Navigate to the directory where the EventRegistration application resides, e.g., /home/user/git/eventregistration

  2. Initialize a new, orphan branch with the following commands

git checkout --orphan android
git reset
rm -rf ./* .gitignore
Note
One-liner command that does the same for those who like living dangerously:
git checkout --orphan android && git reset && rm -rf ./* .gitignore

Create an Android project

  1. Start a new Android project Start new Android project

  2. Select a Basic Activity and click Next

    Select basic activity

  3. Specify project details and click on Finish

    • Application name: EventRegistration-Android

    • Package name: ca.mcgill.ecse321.eventregistration

    • Project location: create the project within the prepared working copy of the git repository say, /home/user/git/eventregistration/EventRegistration-Android`)

    • Select Java as language

    • Click on Finish

      Target platform settings

  4. Wait until the project is built by Gradle, this takes a minute or two

  5. Optional step.

    Tip
    Optionally, to setup version control integration, go to File/Settings…​/Version Control and add the repository as Git root to the project settings
    Set Git root location
    Then, you can issue Git commands from the VCS menu in Android Studio while developing the application. Regardless whether you complete this step or not, you can still use git from the command line, since the project is created in the working directory of your git repository.
  6. Select the Project view in the left pane (instead of the default Android view) and observe three files:

    Project view

    • MainActivity.java: application code is written here (located in app/src/main/java)

    • content_main.xml: layout specifications of the UI are provided in XML (located in app/src/main/res/layout)

    • strings.xml: naming of resources (located in app/src/main/res/values)

  7. Include a dependency for network communication by adding the following line to the build.gradle file located in the app folder to the end within the dependencies{ …​ } part (see figure, but the content is different).

        implementation 'com.loopj.android:android-async-http:1.4.9'
  8. Open the AndroidManifest.xml file (located in app/src/main within the Android project), and add the following XML tag for setting permissions appropriately (before the existing <application> tag)

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="ca.mcgill.ecse321.eventregistration">
    
        <uses-permission android:name="android.permission.INTERNET"/>
        <!-- Existing content with <application> tag -->
    </manifest>
  9. As the gradle build file has changed, click on the Sync link.

  10. Re-build the project by Build | Make Project if still needed.