Skip to content

Commit

Permalink
Upgrade to Android Studio Giraffe, as well as to latest plugins and d…
Browse files Browse the repository at this point in the history
…ependencies. (#160)

"./gradlew build" now works (make sure JAVA_HOME is set properly)
Migrate to version catalogs.
See https://developer.android.com/build/migrate-to-catalogs.
  • Loading branch information
pierredelisle authored Aug 21, 2023
1 parent ee11802 commit bd576f0
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 195 deletions.
158 changes: 122 additions & 36 deletions 3p-ecosystem/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Module-level build file.
// This file t lets you configure build settings for the specific module it is located in.
// Configuring these build settings lets you provide custom packaging options,
// such as additional build types and product flavors, and override settings in the
// main/ app manifest or top-level build script.

/**
* The first section in this file applies among other things the Android Gradle plugin
* to this build and makes the android block available to specify
* Android-specific build options.
*/

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
Expand All @@ -9,21 +21,73 @@ plugins {
id("com.ncorti.ktfmt.gradle") version "0.12.0"
}

/**
* Locate (and possibly download) a JDK used to build your kotlin
* source code. This also acts as a default for sourceCompatibility,
* targetCompatibility and jvmTarget. Note that this does not affect which JDK
* is used to run the Gradle build itself, and does not need to take into
* account the JDK version required by Gradle plugins (such as the
* Android Gradle Plugin)
*/
kotlin {
jvmToolchain(17)
}

/**
* The android block is where you configure all your Android-specific
* build options.
*/
android {
/**
* The app's namespace. Used primarily to access app resources.
*/
namespace = "com.google.homesampleapp"

/**
* compileSdk specifies the Android API level Gradle should use to
* compile your app. This means your app can use the API features included in
* this API level and lower.
*/
compileSdk = 33

/**
* The defaultConfig block encapsulates default settings and entries for all
* build variants and can override some attributes in main/AndroidManifest.xml
* dynamically from the build system. You can configure product flavors to override
* these values for different versions of your app.
*/
defaultConfig {
// DeviceSharingClone: Change this value for the target commissioner cloned app
// Uniquely identifies the package for publishing.
applicationId = "com.google.homesampleapp"

// Defines the minimum API level required to run the app.
minSdk = 27

// Specifies the API level used to test the app.
targetSdk = 33

// Defines the version number of your app.
versionCode = 15

// Defines a user-friendly version name for your app.
versionName = "1.4.1"

// Test Runner.
testInstrumentationRunner = "com.google.homesampleapp.CustomTestRunner"
}

/**
* The buildTypes block is where you can configure multiple build types.
* By default, the build system defines two build types: debug and release. The
* debug build type is not explicitly shown in the default build configuration,
* but it includes debugging tools and is signed with the debug key. The release
* build type applies ProGuard settings and is not signed by default.
*/
buildTypes {
/**
* By default, Android Studio configures the release build type to enable code
* shrinking, using minifyEnabled, and specifies the default ProGuard rules file.
*/
getByName("release") {
isMinifyEnabled = false
proguardFiles(
Expand All @@ -32,6 +96,14 @@ android {
}
}

// FIXME
/**
* To override source and target compatibility (if different from the
* toolchain JDK version), add the following. All of these
* default to the same value as kotlin.jvmToolchain. If you're using the
* same version for these values and kotlin.jvmToolchain, you can
* remove these blocks.
*/
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -49,7 +121,19 @@ android {
}
android.buildFeatures.viewBinding = true

// Specifies one flavor dimension.
/**
* The productFlavors block is where you can configure multiple product flavors.
* This lets you create different versions of your app that can
* override the defaultConfig block with their own settings. Product flavors
* are optional, and the build system does not create them by default.
*
* For example, one can create a free and paid product flavor. Each product flavor
* then specifies its own application ID, so that they can exist on the Google
* Play Store, or an Android device, simultaneously.
*
* If you declare product flavors, you must also declare flavor dimensions
* and assign each flavor to a flavor dimension.
*/
flavorDimensions += "version"
productFlavors {
create("default") {
Expand Down Expand Up @@ -78,59 +162,61 @@ dependencies {
implementation(fileTree(mapOf("dir" to "third_party/connectedhomeip/libs", "include" to listOf("*.jar", "*.so"))))

// Connected Home
implementation("com.google.android.gms:play-services-base:18.2.0")
implementation("com.google.android.gms:play-services-home:16.0.0")
implementation(libs.play.services.base)
implementation(libs.play.services.home)

// AndroidX
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.databinding:databinding-runtime:8.0.2")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.preference:preference:1.2.0")
implementation(libs.appcompat)
implementation(libs.constraintlayout)
implementation(libs.core.ktx)
implementation(libs.databinding.runtime)
implementation(libs.legacy.support.v4)
implementation(libs.preference)

// Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.6.0")
implementation("androidx.navigation:navigation-ui-ktx:2.6.0")
implementation(libs.navigation.fragment.ktx)
implementation(libs.navigation.ui.ktx)

// Lifecycle
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
implementation(libs.lifecycle.extensions)
implementation(libs.lifecycle.livedata.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.lifecycle.viewmodel.ktx)

// Datastore
implementation("androidx.datastore:datastore:1.0.0")
implementation("androidx.datastore:datastore-core:1.0.0")
implementation("com.google.protobuf:protobuf-javalite:3.18.0")
implementation(libs.datastore)
implementation(libs.datastore.core)
implementation(libs.protobuf.javalite)

// Hilt
// https://dagger.dev/hilt/gradle-setup
implementation("com.google.dagger:hilt-android:2.46.1")
kapt("com.google.dagger:hilt-compiler:2.46.1")
implementation("com.google.ar:core:1.38.0")
// TODO: Upgrade to KSP when supported by Hilt/Dagger.
// https://developer.android.com/build/migrate-to-ksp#replace-annotation
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
implementation(libs.core)


// Hilt For instrumentation tests
androidTestImplementation("com.google.dagger:hilt-android-testing:2.44.2")
kaptAndroidTest("com.google.dagger:hilt-compiler:2.46.1")
androidTestImplementation(libs.hilt.android.testing)
kaptAndroidTest(libs.hilt.compiler)

// Task.await()
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")
implementation(libs.kotlinx.coroutines.play.services)

// Other
implementation("com.google.android.material:material:1.9.0")
implementation("com.jakewharton.timber:timber:5.0.1")
implementation(libs.material)
implementation(libs.timber)

// Test
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.5.1")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
androidTestImplementation(libs.espresso.intents)
androidTestImplementation(libs.espresso.contrib)
androidTestImplementation(libs.runner)
androidTestImplementation(libs.rules)
androidTestImplementation(libs.uiautomator)
}

// Issue with androidx.test.espresso:espresso-contrib:3.5.1
Expand All @@ -146,7 +232,7 @@ kapt {
protobuf {
protoc {
// For Apple M1 Chip
val isMac = System.getProperty("os.name").toLowerCase().contains("mac")
val isMac = System.getProperty("os.name").lowercase().contains("mac")
val protocDepSuffix = if (isMac) ":osx-x86_64" else ""
artifact = "com.google.protobuf:protoc:3.14.0" + protocDepSuffix
}
Expand Down
6 changes: 4 additions & 2 deletions 3p-ecosystem/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

<!-- TODO: clarify what specifically requires the permission -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.NFC" />
Expand Down Expand Up @@ -69,7 +70,8 @@

<service android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
android:exported="false">
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
Expand Down
3 changes: 2 additions & 1 deletion 3p-ecosystem/src/main/res/layout/fragment_commissionable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/topBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
Expand Down
2 changes: 1 addition & 1 deletion 3p-ecosystem/src/main/res/layout/fragment_dummy_device.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="@string/device_type">kk
android:hint="@string/device_type">

<AutoCompleteTextView
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion 3p-ecosystem/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/topBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
Expand Down
55 changes: 14 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// This file typically defines the common versions of plugins used by modules in the project.
plugins {
id("com.android.application") version "8.0.2" apply false
id("com.android.library") version "8.0.2" apply false
/**
* Use `apply false` in the top-level build.gradle file to add a Gradle
* plugin as a build dependency but not apply it to the current (root)
* project. Don't use `apply false` in sub-projects. For more information,
* see Applying external plugins with same version to subprojects.
*/

// Gradle Plugin
id("com.android.application") version "8.1.0" apply false
id("com.android.library") version "8.1.0" apply false

// Kotlin plugin
id("org.jetbrains.kotlin.android") version "1.8.22" apply false

id("com.google.dagger.hilt.android") version "2.46.1" apply false
id("androidx.navigation.safeargs") version "2.5.3" apply false
}


//buildscript {
// repositories {
// google()
// mavenCentral()
// maven { url "https://plugins.gradle.org/m2/" }
// }
// dependencies {
// classpath "com.android.tools.build:gradle:7.4.1"
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
// classpath "com.google.protobuf:protobuf-java:3.17.2"
// classpath "com.google.dagger:hilt-android-gradle-plugin:2.42"
// classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
// // NOTE: Do not place your application dependencies here; they belong
// // in the individual module build.gradle files
// }
//}

//task clean(type: Delete) {
// delete rootProject.buildDir
//}


val supportLibVersion = "1.4.1"
val constraintLayoutVersion = "2.1.3"
val coreVersion = "1.7.0"
val coroutinesVersion = "1.6.0"
val dataStoreVersion = "1.0.0"
val materialVersion = "1.5.0"
val protobufVersion = "3.19.4"
val lifecycleVersion = "2.5.1"
val lifecycleExtensionsVersion = "2.2.0"

val runnerVersion = "1.4.0"
val rulesVersion = "1.4.0"
val junitVersion = "4.13.2"
val espressoVersion = "3.4.0"

Loading

0 comments on commit bd576f0

Please sign in to comment.