From bc6edd396349ef10c01b6aef9ef5c577f1087811 Mon Sep 17 00:00:00 2001 From: Rey Mercado Date: Wed, 11 Oct 2023 14:51:08 -0700 Subject: [PATCH] updated starter code to eliminate all errors due to code that has since been deprecated from the time the code was published --- app/build.gradle | 45 ++++++++++--------- app/src/main/AndroidManifest.xml | 3 +- .../guesstheword/screens/game/GameFragment.kt | 6 ++- .../main/res/navigation/main_navigation.xml | 1 - build.gradle | 10 ++--- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 07d343f50..b03edb5a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,21 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: 'kotlin-android-extensions' -apply plugin: "androidx.navigation.safeargs.kotlin" +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'kotlin-kapt' + id 'org.jetbrains.kotlin.android' + id "androidx.navigation.safeargs" +} android { - compileSdkVersion 30 + compileSdkVersion 34 defaultConfig { applicationId "com.example.android.guesstheword" - minSdkVersion 19 - targetSdkVersion 30 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -41,32 +43,33 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = '17' } + namespace 'com.example.android.guesstheword' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' // KTX - implementation 'androidx.core:core-ktx:1.3.1' + implementation 'androidx.core:core-ktx:1.12.0' // Navigation - implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0-rc02" - implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-rc02" + implementation "androidx.navigation:navigation-fragment-ktx:2.7.4" + implementation "androidx.navigation:navigation-ui-ktx:2.7.4" // Lifecycles - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' +// implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ebac42795..68c84b498 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,8 @@ - + diff --git a/app/src/main/java/com/example/android/guesstheword/screens/game/GameFragment.kt b/app/src/main/java/com/example/android/guesstheword/screens/game/GameFragment.kt index 0dbe12118..d031aa809 100644 --- a/app/src/main/java/com/example/android/guesstheword/screens/game/GameFragment.kt +++ b/app/src/main/java/com/example/android/guesstheword/screens/game/GameFragment.kt @@ -22,7 +22,9 @@ import android.view.View import android.view.ViewGroup import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment -import androidx.navigation.fragment.NavHostFragment.findNavController +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProvider +import androidx.navigation.fragment.findNavController import com.example.android.guesstheword.R import com.example.android.guesstheword.databinding.GameFragmentBinding @@ -99,7 +101,7 @@ class GameFragment : Fragment() { */ private fun gameFinished() { val action = GameFragmentDirections.actionGameToScore(score) - findNavController(this).navigate(action) + this.findNavController().navigate(action) } /** diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index 719ff90b5..2972991c6 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -63,7 +63,6 @@ app:popUpTo="@+id/title_destination" /> \ No newline at end of file diff --git a/build.gradle b/build.gradle index 23285629f..54dddfc11 100644 --- a/build.gradle +++ b/build.gradle @@ -17,15 +17,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.9.0' repositories { + mavenCentral() google() - jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:8.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-rc02" + classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.4" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -34,8 +34,8 @@ buildscript { allprojects { repositories { + mavenCentral() google() - jcenter() } } diff --git a/gradle.properties b/gradle.properties index 897244309..7a19e40f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,6 +26,8 @@ org.gradle.jvmargs=-Xmx1536m # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -android.databinding.enableV2=true android.useAndroidX=true android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5e277db02..37915220e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip