Skip to content

Commit 29dbf8e

Browse files
committed
Remove firebase analytics/gms code, update libraries/build, target Android 17, & more
Note: As code is committed upstream, this commit may be rebased over newer code, so updates to this branch may require --force . Also note that ml kit (closed source) claims to send telemetry, and other dependencies used by this app may do so as well- see README for details. Changes include: Privacy & Analytics * Strip out Firebase Analytics, Play Services Measurement, and Firebase Cloud Messaging from app code (dependencies remain, see Warning above) * Strip out Android Tools developer analytics * Request mlkit not to send analytics and add some manifest/proguard build filters remove AD_ID permissions, disable auto app-backups, etc. in AndroidManifest.xml to help with privacy (additional ideas for this are invited!) Dependencies & Libraries * Switch from GMS play-services-tflite to standalone TFLite * Add missing libraries (e.g., documentfile) * Update most libraries to their latest versions * Fix build issues with new protobuf 0.9.6 and newest AGP * Migrate from kapt to ksp Build Configuration * Upgrade to Gradle 9.5.1 * Target SDK 37 (Android 17) * Turn off cloud app backup * Enable minification and shrinkResources for release builds * Add ProGuard rules to allow installRelease build to complete * Auto-copy extra featured skills into the APK Language & Runtime * Update Kotlin to 2.4.0 * Update Java from 11 to 21 UI / UX * Remove onboarding Play ToC agreement (Play-related class was removed, but the agreement is still available for review in the menu) * Update to Material 3 DayNight theme * Add build timestamp to Settings screen Features & Functionality * Selectable GitHub-based model lists (if you want to extend beyond the official list) * Added the 12B Gemma-4 model (for systems with 12GB+ memory) * Added abliterated model option to menu. See related licenses and terms of use before using, and you agree to them use entirely at your own risk. * Larger context windows (may break functionality if you exceed context though) * Increased constants for images, audio, and more * Speculative Decoding (MTP) enabled by default on supported models
1 parent 87822fd commit 29dbf8e

47 files changed

Lines changed: 1030 additions & 695 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
**/.gradle

Android/src/.gitignore

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,39 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
# ==============================================================================
16+
17+
# Gradle files
18+
.gradle/
19+
build/
20+
21+
# Local configuration file (sdk path, etc)
22+
local.properties
23+
24+
# Log/OS Files
25+
*.log
26+
27+
# Android Studio generated files and folders
28+
captures/
29+
.externalNativeBuild/
30+
.cxx/
31+
*.apk
32+
output.json
33+
34+
# IntelliJ
1635
*.iml
36+
.idea/
37+
misc.xml
38+
deploymentTargetDropDown.xml
39+
render.experimental.xml
40+
41+
# Keystore files
42+
*.jks
43+
*.keystore
44+
45+
# Google Services (e.g. APIs or Firebase)
46+
google-services.json
47+
48+
# Android Profiling
49+
*.hprof
1750

18-
.gradle
19-
/local.properties
20-
/.idea/caches
21-
/.idea/libraries
22-
/.idea/modules.xml
23-
/.idea/workspace.xml
24-
/.idea/navEditor.xml
25-
/.idea/assetWizardSettings.xml
2651
.DS_Store
27-
/build
28-
/captures
29-
.externalNativeBuild
30-
.cxx
31-
local.properties

Android/src/app/build.gradle.kts

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import java.text.SimpleDateFormat
17+
import java.util.Date
18+
import java.util.Locale
1619

1720
plugins {
1821
alias(libs.plugins.android.application)
19-
// Note: set apply to true to enable google-services (requires google-services.json).
20-
alias(libs.plugins.google.services) apply false
21-
alias(libs.plugins.kotlin.android)
2222
alias(libs.plugins.kotlin.compose)
2323
alias(libs.plugins.kotlin.serialization)
2424
alias(libs.plugins.protobuf)
2525
alias(libs.plugins.hilt.application)
2626
alias(libs.plugins.oss.licenses)
2727
alias(libs.plugins.ksp)
28-
kotlin("kapt")
2928
}
3029

3130
android {
@@ -49,27 +48,36 @@ android {
4948
buildConfigField("String", "FEEDBACK_API_KEY", "\"\"")
5049

5150
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
52-
}
5351

52+
var buildDate = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(Date())
53+
buildConfigField("String", "BUILD_DATE_TIME", "\"$buildDate\"")
54+
}
5455
buildTypes {
5556
release {
56-
isMinifyEnabled = false
57+
isMinifyEnabled = true
58+
isShrinkResources = true
5759
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
5860
signingConfig = signingConfigs.getByName("debug")
5961
}
6062
}
6163
compileOptions {
62-
sourceCompatibility = JavaVersion.VERSION_11
63-
targetCompatibility = JavaVersion.VERSION_11
64-
}
65-
kotlinOptions {
66-
jvmTarget = "11"
67-
freeCompilerArgs += "-Xcontext-receivers"
64+
sourceCompatibility = JavaVersion.VERSION_21
65+
targetCompatibility = JavaVersion.VERSION_21
6866
}
6967
buildFeatures {
7068
compose = true
7169
buildConfig = true
7270
}
71+
72+
tasks.named("preBuild") {
73+
dependsOn(syncFeaturedSkills)
74+
}
75+
}
76+
77+
val syncFeaturedSkills = tasks.register<Copy>("syncFeaturedSkills") {
78+
description = "Move external skills into build"
79+
from("../../../skills/featured")
80+
into("src/main/assets/skills")
7381
}
7482

7583
dependencies {
@@ -94,30 +102,25 @@ dependencies {
94102
implementation(libs.litertlm)
95103
implementation(libs.commonmark)
96104
implementation(libs.richtext)
97-
implementation(libs.tflite)
98-
implementation(libs.tflite.gpu)
99-
implementation(libs.tflite.support)
100105
implementation(libs.camerax.core)
101106
implementation(libs.camerax.camera2)
102107
implementation(libs.camerax.lifecycle)
103108
implementation(libs.camerax.view)
109+
//noinspection LoginCredentials
104110
implementation(libs.openid.appauth)
105111
implementation(libs.androidx.splashscreen)
106112
implementation(libs.protobuf.javalite)
113+
implementation(libs.protobuf.kotlinlite)
114+
implementation(libs.androidx.documentfile)
107115
implementation(libs.hilt.android)
108116
implementation(libs.hilt.navigation.compose)
109117
implementation(libs.play.services.oss.licenses)
110-
implementation(platform(libs.firebase.bom))
111-
implementation(libs.firebase.analytics)
112-
implementation(libs.firebase.messaging)
113118
implementation(libs.androidx.exifinterface)
114119
implementation(libs.moshi.kotlin)
115-
kapt(libs.hilt.android.compiler)
120+
ksp(libs.hilt.android.compiler)
116121
testImplementation(libs.junit)
117122
androidTestImplementation(libs.androidx.junit)
118123
androidTestImplementation(libs.androidx.espresso.core)
119-
androidTestImplementation(platform(libs.androidx.compose.bom))
120-
androidTestImplementation(libs.androidx.ui.test.junit4)
121124
androidTestImplementation(libs.hilt.android.testing)
122125
debugImplementation(libs.androidx.ui.tooling)
123126
debugImplementation(libs.androidx.ui.test.manifest)
@@ -129,6 +132,20 @@ dependencies {
129132
}
130133

131134
protobuf {
132-
protoc { artifact = "com.google.protobuf:protoc:4.26.1" }
133-
generateProtoTasks { all().forEach { it.plugins { create("java") { option("lite") } } } }
135+
protoc { artifact = "com.google.protobuf:protoc:${libs.protobuf.javalite.get().version}" }
136+
generateProtoTasks { all().forEach { task -> task.builtins { create("java") { option("lite") } } } }
137+
138+
gradle.taskGraph.whenReady {
139+
allTasks.forEach { task ->
140+
if (task.name.contains("ossLicensesTask", ignoreCase = true)) {
141+
task.enabled = false
142+
}
143+
}
144+
}
145+
}
146+
147+
configurations.all {
148+
resolutionStrategy {
149+
force(libs.kotlin.metadata.jvm)
150+
}
134151
}

Android/src/app/proguard-rules.pro

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Proguard configuration for Gson
2+
# Gson uses generic type information stored in a class file when working
3+
# with fields. Proguard removes such information by default, so configure it
4+
# to keep all of it.
5+
-keepattributes Signature
6+
7+
# For using GSON @Expose annotation
8+
-keepattributes *Annotation*
9+
10+
# Gson specific classes
11+
-dontwarn sun.misc.**
12+
#-keep class com.google.gson.stream.** { *; }
13+
14+
# Prevent R8 from leaving Data object members always null
15+
-keepclassmembers,allowobfuscation class * {
16+
@com.google.gson.annotations.SerializedName <fields>;
17+
}
18+
19+
# Keep class TypeToken (respectively its generic signature)
20+
-keep class com.google.gson.reflect.TypeToken { *; }
21+
22+
# Keep any (anonymous) classes extending TypeToken
23+
-keep class * extends com.google.gson.reflect.TypeToken
24+
25+
# Application classes that will be serialized/deserialized over Gson
26+
-keep class com.google.ai.edge.gallery.data.AllowedModel { *; }
27+
-keep class com.google.ai.edge.gallery.data.ModelAllowlist { *; }
28+
-keep class com.google.ai.edge.gallery.data.DefaultConfig { *; }
29+
-keepclassmembers class com.google.ai.edge.gallery.data.AllowedModel { <fields>; }
30+
-keepclassmembers class com.google.ai.edge.gallery.data.ModelAllowlist { <fields>; }
31+
-keepclassmembers class com.google.ai.edge.gallery.data.DefaultConfig { <fields>; }
32+
33+
# Keep mediapipe tasks classes.
34+
-keep public class com.google.mediapipe.tasks.** {
35+
*;
36+
}
37+
38+
# Additional flags to pass to Proguard when processing a binary that uses
39+
# MediaPipe.
40+
41+
# Keep public members of our public interfaces. This also prevents the
42+
# obfuscation of the corresponding methods in classes implementing them,
43+
# such as implementations of PacketCallback#process.
44+
-keep public interface com.google.mediapipe.framework.* {
45+
public *;
46+
}
47+
48+
# This method is invoked by native code.
49+
-keep public class com.google.mediapipe.framework.Packet {
50+
public static *** create(***);
51+
public long getNativeHandle();
52+
public void release();
53+
}
54+
55+
# This method is invoked by native code.
56+
-keep public class com.google.mediapipe.framework.PacketCreator {
57+
*** releaseWithSyncToken(...);
58+
}
59+
60+
# This method is invoked by native code.
61+
-keep public class com.google.mediapipe.framework.MediaPipeException {
62+
<init>(int, byte[]);
63+
}
64+
65+
# Required to use PacketCreator#createProto
66+
-keep class com.google.mediapipe.framework.ProtoUtil$SerializedMessage { *; }
67+
68+
-keep class com.google.ai.edge.gallery.proto.** { *; }
69+
70+
-keep class com.google.protobuf.** { *; }
71+
72+
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
73+
<fields>;
74+
}
75+
76+
-keep class androidx.datastore.** { *; }
77+
78+
-keep class com.google.ai.edge.litert.** { *; }
79+
-keep class com.google.ai.edge.litertlm.** { *; }
80+
81+
-keep class * implements com.google.ai.edge.litertlm.** { *; }
82+
83+
-keep class com.google.ai.edge.gallery.runtime.LlmModelHelper { *; }
84+
-keep class com.google.ai.edge.gallery.ui.llmchat.LlmChatTask { *; }
85+
86+
-keepclasseswithmembernames class * {
87+
native <methods>;
88+
}
89+
-keep class com.google.ai.edge.gallery.tools.** { *; }
90+
91+
-keepclassmembers class * {
92+
@com.google.ai.edge.litertlm.Tool <methods>;
93+
@com.google.ai.edge.litertlm.Tool <fields>;
94+
}
95+
96+
-keepclassmembers class com.google.ai.edge.gallery.tools.params.** {
97+
<fields>;
98+
<init>(...);
99+
}
100+
101+
-keepattributes Signature, AnnotationDefault, EnclosingMethod, InnerClasses
102+
103+
104+
# removing analytics is fine
105+
-dontwarn com.google.android.gms.measurement.**
106+
-dontwarn com.google.firebase.analytics.**
107+
-assumenosideeffects class com.google.android.gms.measurement.** { *; }
108+
-assumenosideeffects class com.google.firebase.analytics.** { *; }
109+
110+
-dontobfuscate

0 commit comments

Comments
 (0)