Create Android Studio Project

Android Studio provides some nice starting templates for creating a project. It gives you boilerplate code so you don't need to write everything from scract.

Open Android Studio on your computer. Click File -> New Project. Give your project a name and package name.

Select next and select Minimum SDK as API-19. In the next windows, select Master/Detail flow template, click next and finish.

If you observe the project file structure, you will find a ItemListAcitity, ItemDetailActivity and ItemDetailFragment.

Before starting developing our app. Let's add required libraries (Realm,Retrofit,RecycleView,CardView and Glide) in build.gradle of both project and app.

  • Realm : A modern and easy to use mobile database (for peristing data)
  • Retrofit : A popular HTTP Client for Java and Android
  • Glide : Aync Image loading and caching library for android
  • Recycle View & Card View : Android SDK libraries for list and material card view.

In main build.gradle file add following below classpath 'com.android.tools.build:gradle:2.1.2'

classpath "io.realm:realm-gradle-plugin:1.1.1"

In app's build.gradle file, add

apply plugin: 'realm-android'

after first line.

Add the following content in dependencies.

Do not remove the existing dependencies

    compile 'com.android.support:recyclerview-v7:24.1.0'
    compile 'com.android.support:cardview-v7:24.1.0'
    compile 'com.android.support:design:24.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'

After doing all of it, click on the sync button to build project.

Hopefully, you won't be getting any error. Make sure to use the same version of recycle view, design and cardview as of the existing appcompat and support libraries.

Please note that default project with create activities, fragments, and layout with item prefix. In our case we changed it to Cupcake :)

At the point, run the app on your device or emulator and then move to next chapter of the tutorial.

results matching ""

    No results matching ""