Simple application using Dagger Android (2.11-2.17), Butterknife (8.7-8.8), and Model-View-Presenter (MVP) with support for Singleton, Activity, Fragment, and child Fragment scopes written in Java and Kotlin
This project is part of a
3-part series
about how to build Android applications using
Dagger 2 (2.11-2.17) with the
Dagger Android extension,
Dagger Android support extension,
Butterknife (8.7-8.8), and Model-View-Presenter (MVP) pattern
with support for @Singleton
, @PerActivity
, @PerFragment
, and @PerChildFragment
scopes.
A Larger Project
This project is a smaller, derivative of a larger project. One of the main purpose of this project is to showcase / walkthrough a specific portion of the larger project's architecture. Take a look at the following larger project for a more real-world example on how to apply Dagger Android (2.11-2.17), Butterknife (8.7-8.8), Clean Architecture, MVP, MVVM, Kotlin, Java Swing, RxJava, RxAndroid, Retrofit 2, Jackson, AutoValue, Yelp Fusion (v3) REST API, Google Maps API, monolithic repo project management with Gradle, JUNit 4, AssertJ, Mockito 2, Robolectric 3, Espresso 2, and Java best practices and design patterns.
This project now uses Android Studio 3.2.0-rc02. Previous versions of Android Studio (2.4/2.3.3 and below) will no longer be able to build this project.
The following major Dagger 2 and Butterknife versions works with this project;
There are 4 main branches:
Activity
and Fragment
classes with a minSdkVersion
of 17.AppCompatActivity
and support Fragment
classes with a minSdkVersion
of 14.Why is the minSdkVersion
of the non-support setup in master 17? Can it be lower?
There are 2 main reasons why the minSdkVersion
of the non-support setup can only be as low as 17.
Thus, the lowest minSdkVersion
supported for the non-support setup in master is 17.
It cannot be lower.
What about the minSdkVersion
of the support setup in master-support? Can it be lower than 14?
No. The dagger.android.support API only supports minSdkVersion
as low as 14.
This demonstrates dagger.android, Butterknife, and MVP setup using 5 examples:
For a quick overview of dagger-android 2.11 usage with support for @Singleton
, @PerActivity
,
@PerFragment
, and @PerChildFragment
scopes, take a look at
this gist.
Read the walkthrough for the complete guide with proper step-by-step setup and explanations.
Read the blogs for a complete walkthrough of this app:
@Singleton
, @PerActivity
, @PerFragment
, and @PerChildFragment
scopes.
ARTICLE
If you don't like reading blogs or are just too "pro" and would like to just explore the repository, you may want to look at the issues instead;
Copyright 2018 Vandolf Estrellado
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.