From cee6bc9729858801a7fc980a810cb61d8265a879 Mon Sep 17 00:00:00 2001 From: Chandler Cheng Date: Wed, 11 Sep 2019 09:46:20 +1200 Subject: [PATCH 1/2] Upgrade to latest Android and gradle version --- app/build.gradle | 18 +++++++++--------- build.gradle | 11 ++++++++++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e03bbd5..8ebfd18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.1" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.mindorks.example.android_dagger2_example" minSdkVersion 16 - targetSdkVersion 25 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,15 +20,15 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.1.0' - testCompile 'junit:junit:4.12' + implementation 'com.android.support:appcompat-v7:28.0.0' + testImplementation 'junit:junit:4.12' - compile "com.google.dagger:dagger:2.8" + implementation "com.google.dagger:dagger:2.8" annotationProcessor "com.google.dagger:dagger-compiler:2.8" - provided 'javax.annotation:jsr250-api:1.0' - compile 'javax.inject:javax.inject:1' +// compileOnly 'javax.annotation:jsr250-api:1.0' + implementation 'javax.inject:javax.inject:1' } diff --git a/build.gradle b/build.gradle index 74b2ab0..9e9e3d1 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,14 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.5.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +20,10 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f..9b59a74 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Wed Sep 11 09:19:55 NZST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip From d1e151fa95ffccd83c54f185c4e2384232a8e5b6 Mon Sep 17 00:00:00 2001 From: Chandler Cheng Date: Fri, 13 Sep 2019 16:35:41 +1200 Subject: [PATCH 2/2] Delete ActivityModule --- .../android_dagger2_example/MainActivity.java | 3 -- .../di/ActivityContext.java | 15 -------- .../di/component/ActivityComponent.java | 4 +-- .../di/module/ActivityModule.java | 34 ------------------- 4 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 app/src/main/java/com/mindorks/example/android_dagger2_example/di/ActivityContext.java delete mode 100644 app/src/main/java/com/mindorks/example/android_dagger2_example/di/module/ActivityModule.java diff --git a/app/src/main/java/com/mindorks/example/android_dagger2_example/MainActivity.java b/app/src/main/java/com/mindorks/example/android_dagger2_example/MainActivity.java index e0ad07f..d2d89d0 100644 --- a/app/src/main/java/com/mindorks/example/android_dagger2_example/MainActivity.java +++ b/app/src/main/java/com/mindorks/example/android_dagger2_example/MainActivity.java @@ -1,6 +1,5 @@ package com.mindorks.example.android_dagger2_example; -import android.content.res.Resources; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; @@ -10,7 +9,6 @@ import com.mindorks.example.android_dagger2_example.data.model.User; import com.mindorks.example.android_dagger2_example.di.component.ActivityComponent; import com.mindorks.example.android_dagger2_example.di.component.DaggerActivityComponent; -import com.mindorks.example.android_dagger2_example.di.module.ActivityModule; import javax.inject.Inject; @@ -27,7 +25,6 @@ public class MainActivity extends AppCompatActivity { public ActivityComponent getActivityComponent() { if (activityComponent == null) { activityComponent = DaggerActivityComponent.builder() - .activityModule(new ActivityModule(this)) .applicationComponent(DemoApplication.get(this).getComponent()) .build(); } diff --git a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/ActivityContext.java b/app/src/main/java/com/mindorks/example/android_dagger2_example/di/ActivityContext.java deleted file mode 100644 index 08c2c25..0000000 --- a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/ActivityContext.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mindorks.example.android_dagger2_example.di; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.inject.Qualifier; - -/** - * Created by janisharali on 25/12/16. - */ - -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -public @interface ActivityContext { -} diff --git a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/component/ActivityComponent.java b/app/src/main/java/com/mindorks/example/android_dagger2_example/di/component/ActivityComponent.java index a723d89..194d22f 100644 --- a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/component/ActivityComponent.java +++ b/app/src/main/java/com/mindorks/example/android_dagger2_example/di/component/ActivityComponent.java @@ -2,7 +2,7 @@ import com.mindorks.example.android_dagger2_example.MainActivity; import com.mindorks.example.android_dagger2_example.di.PerActivity; -import com.mindorks.example.android_dagger2_example.di.module.ActivityModule; +import com.mindorks.example.android_dagger2_example.di.module.ApplicationModule; import dagger.Component; @@ -11,7 +11,7 @@ */ @PerActivity -@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) +@Component(dependencies = ApplicationComponent.class, modules = ApplicationModule.class) public interface ActivityComponent { void inject(MainActivity mainActivity); diff --git a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/module/ActivityModule.java b/app/src/main/java/com/mindorks/example/android_dagger2_example/di/module/ActivityModule.java deleted file mode 100644 index f5aec7d..0000000 --- a/app/src/main/java/com/mindorks/example/android_dagger2_example/di/module/ActivityModule.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mindorks.example.android_dagger2_example.di.module; - -import android.app.Activity; -import android.content.Context; - -import com.mindorks.example.android_dagger2_example.di.ActivityContext; - -import dagger.Module; -import dagger.Provides; - -/** - * Created by janisharali on 08/12/16. - */ - -@Module -public class ActivityModule { - - private Activity mActivity; - - public ActivityModule(Activity activity) { - mActivity = activity; - } - - @Provides - @ActivityContext - Context provideContext() { - return mActivity; - } - - @Provides - Activity provideActivity() { - return mActivity; - } -}