diff --git a/app/build.gradle b/app/build.gradle index b143b08..33fa761 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,11 +4,11 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { applicationId "com.google.android.samples.dynamiccodeloading" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 33 versionCode 33 versionName "1.0.33" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -51,18 +51,19 @@ dependencies { api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - api 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.core:core-ktx:1.0.1' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + api 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation "com.google.android.play:core:1.4.1" + implementation "com.google.android.play:core:1.10.3" - daggerApi 'com.google.dagger:dagger:2.16' - api 'com.google.dagger:dagger-android-support:2.16' + daggerApi 'com.google.dagger:dagger:2.44.2' + api 'com.google.dagger:dagger-android-support:2.44.2' - kapt 'com.google.dagger:dagger-compiler:2.16' + kapt 'com.google.dagger:dagger-compiler:2.44.2' - implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04' - androidTestImplementation 'androidx.test:rules:1.2.0-alpha04' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + androidTestImplementation 'androidx.test:rules:1.5.0' } diff --git a/app/src/androidTest/java/com/google/android/samples/dynamiccodeloading/MainActivityTest.kt b/app/src/androidTest/java/com/google/android/samples/dynamiccodeloading/MainActivityTest.kt index 38d9eae..c704bcd 100644 --- a/app/src/androidTest/java/com/google/android/samples/dynamiccodeloading/MainActivityTest.kt +++ b/app/src/androidTest/java/com/google/android/samples/dynamiccodeloading/MainActivityTest.kt @@ -44,7 +44,7 @@ class MainActivityTest { @Before fun before() { PreferenceManager.getDefaultSharedPreferences( - InstrumentationRegistry.getInstrumentation().getTargetContext().applicationContext + InstrumentationRegistry.getInstrumentation().targetContext.applicationContext ).edit().clear().commit() } @@ -62,7 +62,7 @@ class MainActivityTest { onView(withId(R.id.saveButton)).perform(click()) - InstrumentationRegistry.getInstrumentation().runOnMainSync(Runnable { mActivityTestRule.activity.recreate() }) + InstrumentationRegistry.getInstrumentation().runOnMainSync({ mActivityTestRule.activity.recreate() }) val textView = onView(withId(R.id.counterText)) textView.check(matches(withText("3"))) diff --git a/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/MyApplication.kt b/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/MyApplication.kt index df19bbf..346e94f 100644 --- a/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/MyApplication.kt +++ b/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/MyApplication.kt @@ -16,7 +16,6 @@ */ package com.google.android.samples.dynamiccodeloading -import androidx.annotation.MainThread import com.google.android.play.core.splitcompat.SplitCompatApplication import com.google.android.samples.dynamiccodeloading.di.BaseComponent import com.google.android.samples.dynamiccodeloading.di.DaggerBaseComponent diff --git a/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/di/BaseDagger.kt b/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/di/BaseDagger.kt index d74cc13..2737590 100644 --- a/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/di/BaseDagger.kt +++ b/app/src/dagger/java/com/google/android/samples/dynamiccodeloading/di/BaseDagger.kt @@ -57,15 +57,15 @@ object BaseModule { if (storageFeature != null){ return storageFeature as StorageFeature } - try { + return try { // Get the instance of the StorageFeature.Provider, pass it the BaseComponent which fulfills the // StorageFeature.Dependencies contract, and get the StorageFeature instance in return. val provider = Class.forName(PROVIDER_CLASS).kotlin.objectInstance as StorageFeature.Provider - return provider.get(baseComponent) + provider.get(baseComponent) .also { storageFeature = it } //cache the value for later calls } catch (e: ClassNotFoundException){ Log.e(TAG, "Provider class not found", e) - return null + null } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 33357af..deff366 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,7 +25,8 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="AllowBackup,GoogleAppIndexingWarning"> - + diff --git a/app/src/main/java/com/google/android/samples/dynamiccodeloading/MainActivity.kt b/app/src/main/java/com/google/android/samples/dynamiccodeloading/MainActivity.kt index 85a1d0c..f741048 100644 --- a/app/src/main/java/com/google/android/samples/dynamiccodeloading/MainActivity.kt +++ b/app/src/main/java/com/google/android/samples/dynamiccodeloading/MainActivity.kt @@ -21,7 +21,7 @@ import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider /** * The single, main activity of this sample. @@ -48,7 +48,7 @@ class MainActivity : AppCompatActivity() { saveText = findViewById(R.id.saveText) saveButton = findViewById(R.id.saveButton) - viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) + viewModel = ViewModelProvider(this)[MainViewModel::class.java] incrementButton.setOnClickListener { viewModel.incrementCounter() @@ -58,7 +58,7 @@ class MainActivity : AppCompatActivity() { viewModel.saveCounter() } - viewModel.counter.observe(this, Observer { + viewModel.counter.observe(this, { counterText.text = (it ?: 0).toString() }) diff --git a/build.gradle b/build.gradle index e89c4bd..673967e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,18 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.30' + ext.kotlin_version = '1.7.21' repositories { maven { - url "http://storage.googleapis.com/r8-releases/raw/master" + url "https://storage.googleapis.com/r8-releases/raw/master" } google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools:r8:878ec25559ca91497517345ec3a6c16102b7025c' // Must be before the Gradle Plugin for Android. - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools:r8:3.3.75' // Must be before the Gradle Plugin for Android. + classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -22,7 +22,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1aa8bf9..677255a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 25 14:22:23 CEST 2019 +#Sat Dec 17 13:53:34 IST 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-rc-1-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/storage/build.gradle b/storage/build.gradle index 15ec4e1..f929131 100644 --- a/storage/build.gradle +++ b/storage/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 33 versionCode 1 versionName "1.0" } @@ -44,5 +44,5 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(':app') - kapt 'com.google.dagger:dagger-compiler:2.16' + kapt 'com.google.dagger:dagger-compiler:2.44.2' }