Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
51aa000
First commit with the base template
JoseAlcerreca Aug 19, 2022
16206fc
--amend
JoseAlcerreca Aug 31, 2022
2b04b0f
Adds CI to base (#2)
JoseAlcerreca Sep 7, 2022
7d9f9b8
CI - adds customizer check (base) (#11)
JoseAlcerreca Sep 7, 2022
59d3389
Update dependency gradle to v7.5.1 (#7)
renovate[bot] Sep 7, 2022
3e6fc18
Update dependency androidx.compose.material3:material3 to v1.0.0-beta…
renovate[bot] Sep 7, 2022
bf1056d
Delete app/schemas/android.template.data.local.database.AppDatabase d…
JoseAlcerreca Sep 7, 2022
be9a6c4
Update actions/setup-java action to v3 (base) (#13)
renovate[bot] Sep 8, 2022
0368624
Update dependency androidx.navigation:navigation-compose to v2.5.2 (#15)
renovate[bot] Sep 8, 2022
6c4e581
Update dependency androidx.core:core-ktx to v1.9.0 (#16)
renovate[bot] Sep 8, 2022
9666296
Update all dependencies 7.3.0-rc01 to v7.3.0 (#22)
renovate[bot] Sep 19, 2022
5ac447c
Update all dependencies (base) (#24)
renovate[bot] Sep 30, 2022
668c40c
Update all dependencies (base) (#27)
renovate[bot] Oct 31, 2022
60c4c29
Adds Compose compiler to the version catalog just so that Renovate ca…
JoseAlcerreca Oct 31, 2022
922997b
Update all dependencies (base) (#29)
renovate[bot] Nov 7, 2022
f74df17
Update all dependencies (base) (#32)
renovate[bot] Nov 15, 2022
bd29a90
Update all dependencies 2.44.1 to v2.44.2 (#38)
renovate[bot] Nov 15, 2022
55dea66
[Customizer] removes additional files (#40)
JoseAlcerreca Nov 15, 2022
1180dca
Updates title for samples indexer
JoseAlcerreca Nov 25, 2022
0bb9aef
Adds screenshot and new instructions to base README
JoseAlcerreca Nov 25, 2022
4195c0b
Update dependency gradle 7.5.1 to v7.6 (#42)
renovate[bot] Nov 28, 2022
55fc30a
Create packaging.yaml
JoseAlcerreca Nov 29, 2022
82aa83b
Update all dependencies 1.3.1 to v1.3.2 (#49)
renovate[bot] Dec 8, 2022
08d938d
Update kotlin
renovate[bot] Jan 18, 2023
66099c3
Update all dependencies
renovate[bot] Jan 18, 2023
8955897
Add screenshots H2
tunjid Jan 18, 2023
5b8197e
Update dependency com.google.devtools.ksp 1.8.0-1.0.8 to v1.8.0-1.0.9
renovate[bot] Jan 27, 2023
02f3661
Update kotlin
renovate[bot] Feb 9, 2023
0dde0b1
Update all dependencies
renovate[bot] Feb 13, 2023
1bfa29a
Updates jvmTarget to 11
JoseAlcerreca Feb 15, 2023
9dd2372
Updates jvmTarget to 17
JoseAlcerreca Feb 15, 2023
8605fc5
Update JavaVersion
JoseAlcerreca Feb 15, 2023
7cd776d
Update dependency gradle 8.0 to v8.0.1
renovate[bot] Feb 18, 2023
fdc4d44
Update dependency androidx.compose.compiler:compiler 1.4.2 to v1.4.3
renovate[bot] Feb 24, 2023
9831008
Update all dependencies
renovate[bot] Mar 6, 2023
5e1666e
Update all dependencies 2.5.1 to v2.6.0
renovate[bot] Mar 9, 2023
58eb32a
emit error in MyModelViewModel
chinachen01 Feb 16, 2023
958890f
Migrates to Compose BOM
JoseAlcerreca Mar 24, 2023
55c24c2
Cleanup
JoseAlcerreca Mar 24, 2023
50df14d
Update all dependencies
renovate[bot] Apr 13, 2023
08b4e49
Updates to Java 17
JoseAlcerreca Apr 18, 2023
b0d9b6e
Update to Java 17 on CI
JoseAlcerreca Apr 19, 2023
0c0dc6d
CI config for Java 17
JoseAlcerreca Apr 19, 2023
a5455b5
Update instrumented_tests.yml to Java 17
JoseAlcerreca Apr 19, 2023
8ac3d08
Update kotlin
renovate[bot] Apr 20, 2023
9566fd4
Update all dependencies
renovate[bot] Apr 21, 2023
ab4b7a8
Update all dependencies
renovate[bot] May 3, 2023
4192028
Update all dependencies
renovate[bot] May 11, 2023
fca6e5a
Replace produceState with collectAsStateWithLifecycle
moyheen May 27, 2023
75aaaa0
Update kotlin
renovate[bot] Aug 24, 2023
cafac3d
Pins kotlin and ksp to 1.9.0
JoseAlcerreca Aug 28, 2023
7a1a0e1
Update all dependencies
renovate[bot] Aug 28, 2023
c0a3518
Sets compile and target SDKs to 34
JoseAlcerreca Aug 28, 2023
380ead9
Update kotlin
renovate[bot] Aug 29, 2023
fb49a4a
Update all dependencies 2.47 to v2.48
renovate[bot] Aug 31, 2023
3a3f135
Update all dependencies
renovate[bot] Oct 25, 2023
e1280a8
Update all dependencies
renovate[bot] Nov 2, 2023
040c289
Update all dependencies 8.1.2 to v8.1.3
renovate[bot] Nov 8, 2023
8d317fe
Update kotlin
renovate[bot] Nov 7, 2023
c55b20b
Update all dependencies
renovate[bot] Nov 16, 2023
3f02133
Update all dependencies
renovate[bot] Nov 30, 2023
d3c9e8b
Update kotlin
renovate[bot] Dec 25, 2023
c5ac05d
Update libs.versions.toml
JoseAlcerreca Jan 2, 2024
b19ccde
Update all dependencies
renovate[bot] Dec 20, 2023
0fc9dce
Update kotlin
renovate[bot] Jan 10, 2024
2301160
Update all dependencies
renovate[bot] Jan 10, 2024
7111561
Move emulator tests to ubuntu and enable KVM
JoseAlcerreca Jan 22, 2024
6ca621e
Update all dependencies
renovate[bot] Jan 28, 2024
b952762
Update dependency com.google.devtools.ksp 1.9.22-1.0.16 to v1.9.22-1.…
renovate[bot] Jan 19, 2024
996951a
Update all dependencies
renovate[bot] Feb 21, 2024
58fd4fd
Update kotlin
renovate[bot] Feb 26, 2024
208ad17
Update all dependencies
renovate[bot] May 14, 2024
6204053
Update libs.versions.toml
JoseAlcerreca May 17, 2024
4216a83
Update kotlin
renovate[bot] May 17, 2024
9f2d1ed
Update Kotlin and KSP versions and migrate to Compose gradle plugin (…
jsytal1 Jul 18, 2024
19ec83e
Update all dependencies
renovate[bot] Jul 18, 2024
8bae9f7
Update all dependencies
renovate[bot] Aug 5, 2024
f579d52
Update kotlin
renovate[bot] Aug 7, 2024
c52e325
Update all dependencies
renovate[bot] Oct 2, 2024
7c7b5a9
Update kotlin
renovate[bot] Nov 8, 2024
7ed7a4f
Update all dependencies
renovate[bot] Nov 14, 2024
29bb9f3
Compile SDK = 35
JoseAlcerreca Nov 14, 2024
25d8343
Fixes error in customizer when the application name matches the original
JoseAlcerreca Nov 18, 2024
fef4ee6
Update all dependencies (#175)
renovate[bot] Dec 13, 2024
66529d5
Update all dependencies (#178)
renovate[bot] Jan 13, 2025
c67fc80
Update all dependencies
renovate[bot] Apr 9, 2025
fa301a4
Update all dependencies (base) (#184)
renovate[bot] Sep 1, 2025
cdb6de4
Update all dependencies (#189)
renovate[bot] Nov 20, 2025
a0ef504
Migrate from Navigation 2 to Navigation 3
dturner Nov 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/build_and_local_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and local test

on:
push:
branches: [ "base", "multimodule" ]
pull_request:
branches: [ "base", "multimodule" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- name: set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'zulu'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build debug
run: ./gradlew assembleDebug --stacktrace

- name: Run local tests
run: ./gradlew testDebug --stacktrace

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v5
with:
name: build-outputs
path: ./app/build/outputs

- name: Upload build reports
if: always()
uses: actions/upload-artifact@v5
with:
name: build-reports
path: ./app/build/reports

- name: Clean before running customizer
run: git clean -fx .

- name: Run customizer script
run: bash customizer.sh com.android.blah MyNewModel MyNewApplication

- name: "Check that customizer ran correctly"
uses: andstor/file-existence-action@v3
with:
files: "app/src/main/java/com/android/blah/MyNewApplication.kt"
fail: false

- name: "Check that customizer removed all unnecessary files"
id: customizer_rm
uses: andstor/file-existence-action@v3
with:
files: ".git/config"
fail: false
- name: "Fail if unnecessary files were not deleted"
if: steps.customizer_rm.outputs.files_exists == 'true'
run: exit 1
47 changes: 47 additions & 0 deletions .github/workflows/instrumented_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Instrumented tests

on:
push:
branches: [ "base", "multimodule" ]
pull_request:
branches: [ "base", "multimodule" ]

jobs:
androidTest:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
api-level: [23, 26, 29]

steps:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm

- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'zulu'

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86
disable-animations: true
script: ./gradlew connectedCheck --stacktrace

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v5
with:
name: test-reports-${{ matrix.api-level }}
path: ./app/build/reports/androidTests
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
31 changes: 31 additions & 0 deletions .google/packaging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2020 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
status: PUBLISHED
technologies: [Android]
categories:
- AndroidTesting
- AndroidArchitecture
- AndroidArchitectureUILayer
- AndroidArchitectureDataLayer
languages: [Kotlin]
solutions: [Mobile]
github: android/architecture-templates
level: INTERMEDIATE
license: apache2
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Architecture starter template (single module)
==================

This template is compatible with the latest **stable** version of Android Studio.

## Screenshots
![Screenshot](https://github.com/android/architecture-templates/raw/main/screenshots.png)

## Features

* Room Database
* Hilt
* ViewModel, read+write
* UI in Compose, list + write (Material3)
* Navigation
* Repository and data source
* Kotlin Coroutines and Flow
* Unit tests
* UI tests using fake data with Hilt

## Usage

1. Clone this branch

```
git clone https://github.com/android/architecture-templates.git --branch base
```

2. Run the customizer script:

```
./customizer.sh your.package.name DataItemType [MyApplication]
```

Where `your.package.name` is your app ID (should be lowercase) and `DataItemType` is used for the
name of the screen, exposed state and data base entity (should be PascalCase). You can add an optional application name.

# License

Now in Android is distributed under the terms of the Apache License (Version 2.0). See the
[license](LICENSE) for more information.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
134 changes: 134 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "ASIS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.hilt.gradle)
alias(libs.plugins.ksp)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.serialization)
}

android {
namespace = "android.template"
compileSdk = 36

defaultConfig {
applicationId = "android.template"
minSdk = 23
targetSdk = 36
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "android.template.HiltTestRunner"
vectorDrawables {
useSupportLibrary = true
}

// Enable room auto-migrations
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

buildFeatures {
compose = true
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {

val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Core Android dependencies
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)

// Hilt Dependency Injection
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
// Hilt and instrumented tests.
androidTestImplementation(libs.hilt.android.testing)
kaptAndroidTest(libs.hilt.android.compiler)
// Hilt and Robolectric tests.
testImplementation(libs.hilt.android.testing)
kaptTest(libs.hilt.android.compiler)

// Arch Components
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)

// Compose
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)
// Tooling
debugImplementation(libs.androidx.compose.ui.tooling)
// Instrumented tests
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
debugImplementation(libs.androidx.compose.ui.test.manifest)

// Local tests: jUnit, coroutines, Android runner
testImplementation(libs.junit)
testImplementation(libs.kotlinx.coroutines.test)

// Instrumented tests: jUnit rules and runners

androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.runner)

// Navigation 3
implementation(libs.androidx.navigation3.ui)
implementation(libs.androidx.navigation3.runtime)
implementation(libs.androidx.lifecycle.viewmodel.navigation3)
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
32 changes: 32 additions & 0 deletions app/src/androidTest/java/android/template/HiltTestRunner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package android.template

import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
import dagger.hilt.android.testing.HiltTestApplication

/**
* A custom runner to set up the instrumented application class for tests.
*/
class HiltTestRunner : AndroidJUnitRunner() {

override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
Loading