From f81ce238dec3d627e272162ec85d18fbd84224f7 Mon Sep 17 00:00:00 2001 From: "Pietro F. Maggi" Date: Wed, 17 Aug 2022 12:12:13 +0200 Subject: [PATCH 1/3] Updates build dependencies --- app/build.gradle | 48 +++++++++++------------- build.gradle | 15 +++----- gradle.properties | 3 -- gradle/wrapper/gradle-wrapper.properties | 4 +- 4 files changed, 29 insertions(+), 41 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 04ce6af..7532cc7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,18 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -apply plugin: 'com.android.application' -apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' -apply plugin: 'kotlin-android' -apply plugin: 'com.google.android.gms.oss-licenses-plugin' + +plugins { + id 'com.android.application' + id 'com.google.android.gms.strict-version-matcher-plugin' + id 'kotlin-android' + id 'com.google.android.gms.oss-licenses-plugin' +} android { - compileSdkVersion 30 + compileSdkVersion 32 defaultConfig { applicationId "com.amapi.extensibility.demo" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 32 versionCode 1 versionName "1.0" @@ -38,9 +41,6 @@ android { } compileOptions { - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -51,29 +51,25 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' - implementation 'io.grpc:grpc-okhttp:1.44.0' // CURRENT_GRPC_VERSION implementation 'com.google.android.libraries.enterprise.amapi:amapi:1.0.1' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.5.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0' + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.appcompat:appcompat:1.5.0' + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.appcompat:appcompat:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.lifecycle:lifecycle-common-java8:2.5.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'com.google.guava:guava:30.0-android' - implementation 'androidx.core:core:1.3.2' + implementation 'androidx.core:core-ktx:1.8.0' implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test:rules:1.1.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.1.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + androidTestImplementation 'androidx.test:rules:1.4.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/build.gradle b/build.gradle index db98b59..c35ccb9 100644 --- a/build.gradle +++ b/build.gradle @@ -12,23 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// Top-level build file where you can add configuration options common to all sub-projects/modules. + buildscript { - ext.kotlin_version = "1.6.10" + ext.kotlin_version = "1.7.10" repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools:r8:3.0.65' + classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.tools.build:gradle:4.0.2' - classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.1' - classpath 'net.sf.proguard:proguard-gradle:6.2.2' - classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.4' + classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5' } } diff --git a/gradle.properties b/gradle.properties index 26ebcdf..24f0e7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,8 +16,5 @@ org.gradle.jvmargs=-Xmx1536m # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Disable R8 until R8 is able to fully replace proguard -android.enableR8=false # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7545dab..2177c32 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Aug 14 10:59:44 CDT 2020 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +zipStoreBase=GRADLE_USER_HOME From 4f5f3eac1ae6e5417cc6ef6ab9bd3ab1c9807932 Mon Sep 17 00:00:00 2001 From: "Pietro F. Maggi" Date: Wed, 17 Aug 2022 12:36:40 +0200 Subject: [PATCH 2/3] Adds viewbinding --- app/build.gradle | 12 ++++++- .../demo/commands/CommandActivity.kt | 33 +++++++++++-------- app/src/main/res/layout/activity_command.xml | 5 ++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7532cc7..a1ac035 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,16 +41,26 @@ android { } compileOptions { + // Flag to enable support for the new language APIs + coreLibraryDesugaringEnabled true + // Sets Java compatibility to Java 8 sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { - freeCompilerArgs = ['-Xjvm-default=enable'] jvmTarget = '1.8' } + + buildFeatures { + viewBinding true + } } dependencies { + // Version 1.2.0 requires AGP 7.3.0-beta03+ + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + implementation 'io.grpc:grpc-okhttp:1.44.0' // CURRENT_GRPC_VERSION implementation 'com.google.android.libraries.enterprise.amapi:amapi:1.0.1' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/app/src/main/java/com/amapi/extensibility/demo/commands/CommandActivity.kt b/app/src/main/java/com/amapi/extensibility/demo/commands/CommandActivity.kt index 23ace23..242354b 100644 --- a/app/src/main/java/com/amapi/extensibility/demo/commands/CommandActivity.kt +++ b/app/src/main/java/com/amapi/extensibility/demo/commands/CommandActivity.kt @@ -16,36 +16,41 @@ package com.amapi.extensibility.demo.commands import android.content.Intent import android.os.Bundle -import android.widget.Button -import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.ViewModelProvider import com.amapi.extensibility.demo.R +import com.amapi.extensibility.demo.databinding.ActivityCommandBinding import com.google.android.gms.oss.licenses.OssLicensesMenuActivity class CommandActivity : AppCompatActivity() { private lateinit var commandViewModel: CommandViewModel + private lateinit var binding: ActivityCommandBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_command) - commandViewModel = ViewModelProvider(this).get(CommandViewModel::class.java) + binding = ActivityCommandBinding.inflate(layoutInflater) + setContentView(binding.root) + + commandViewModel = ViewModelProvider(this)[CommandViewModel::class.java] commandViewModel.commandResultLiveData.observe(this) { results -> findViewById(R.id.command_result_textview).apply { text = results } } - findViewById