Skip to content

Commit 8e499ff

Browse files
Merge branch 'stage' into ADFA-934-build-output-timestamp
2 parents ef35dc6 + 85c52cf commit 8e499ff

3 files changed

Lines changed: 86 additions & 16 deletions

File tree

‎app/proguard-rules.pro‎

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
-dontnote **
55
-dontobfuscate
66

7+
# ADFA-3604: R8's optimize pass (inlining/method merging) can silently
8+
# retarget a call to the wrong method when it fails to parse Kotlin 2.3.0
9+
# metadata (see "R8: An error occurred when parsing kotlin metadata" in the
10+
# build log) -- observed corrupting calls to utils.TestModeUtilsKt.isTestMode
11+
# into calls to the unrelated, device-missing dalvik.system.VMRuntime.isTestMode,
12+
# crashing every release build on launch. Shrinking (dead-code removal) is
13+
# what actually cuts dex size; the optimize passes are the risky part given
14+
# this R8/Kotlin version mismatch, so disable only optimization.
15+
-dontoptimize
16+
717
-keep class javax.** { *; }
818
-keep class jdkx.** { *; }
919

@@ -19,6 +29,42 @@
1929
# Builder model implementations
2030
-keep class com.itsaky.androidide.builder.model.** { *; }
2131

32+
# lsp/kotlin registers its own IntelliJ project/application services -- some
33+
# by class name in lsp/kotlin/src/main/resources/META-INF/kt-lsp/kt-lsp.xml,
34+
# the rest via ::class literals in
35+
# lsp/kotlin/.../registrar/AnalysisApiServiceProviders.kt, which PicoContainer
36+
# then instantiates reflectively via each class's no-arg constructor. A
37+
# ::class literal doesn't count as an actual `new` call to R8, so it kept
38+
# stripping "unused" no-arg constructors one class at a time as each was
39+
# discovered on-device (ClassNotFoundException on DirectInheritorsProvider,
40+
# then a PicoInitializationException on ModuleDependentsProvider's missing
41+
# constructor). Keep the whole package rather than list every implementation
42+
# class in AnalysisApiServiceProviders.kt individually.
43+
-keep class com.itsaky.androidide.lsp.kotlin.compiler.services.** { *; }
44+
45+
# Kotlin Analysis API (bundled in subprojects/kotlin-analysis-api, used by the
46+
# Kotlin LSP). subprojects/kotlin-analysis-api/consumer-rules.pro keeps every
47+
# class this jar's own IntelliJ plugin XML descriptors and ServiceLoader
48+
# entries reference by name, but on-device testing kept surfacing distinct
49+
# reflection paths that narrow list didn't cover -- not just inside this jar,
50+
# but in other lsp/kotlin runtime dependencies too (Caffeine picks a cache
51+
# implementation from dozens of codegenned variant classes at runtime; a
52+
# protobuf-lite message field is resolved by name string; lsp/kotlin's own
53+
# kt-lsp.xml above; and a NullPointerException deep in IntelliJ's own
54+
# JavaCoreApplicationEnvironment bootstrap, verified absent on an unshrunk
55+
# debug build). Each fix was quick but the next gap kept appearing elsewhere
56+
# in the same dependency graph, so rather than keep discovering them one
57+
# on-device crash at a time, keep every runtime dependency lsp/kotlin pulls in
58+
# whole. This gives up the dex-size reduction for this whole dependency graph;
59+
# see ADFA-3604 for the size trade-off.
60+
-keep class org.jetbrains.kotlin.** { *; }
61+
-keep class com.github.benmanes.caffeine.** { *; }
62+
-keep class kotlin.reflect.** { *; }
63+
-keep class kotlin.script.** { *; }
64+
-keep class kotlinx.coroutines.internal.** { *; }
65+
-keep class one.util.streamex.** { *; }
66+
-keep class gnu.trove.** { *; }
67+
2268
# Eclipse
2369
-keep class org.eclipse.** { *; }
2470

@@ -66,10 +112,12 @@
66112
}
67113
-keep class com.itsaky.androidide.utils.DialogUtils { public <methods>; }
68114

69-
# APK Metadata
70-
-keep class com.itsaky.androidide.models.ApkMetadata { *; }
71-
-keep class com.itsaky.androidide.models.ArtifactType { *; }
72-
-keep class com.itsaky.androidide.models.MetadataElement { *; }
115+
# Gson model classes deserialized only via reflection (gson.fromJson(...,
116+
# X::class.java)), same "R8 strips the unreachable constructor" issue as
117+
# templates.impl.zip below. Covers OpenedFilesCache/OpenedFile (no prior
118+
# rule) as well as the APK metadata classes already listed individually.
119+
-keep class com.itsaky.androidide.models.** { *; }
120+
-keep class com.itsaky.androidide.lsp.debug.model.** { *; }
73121

74122
# Parcelable
75123
-keepclassmembers class * implements android.os.Parcelable {
@@ -88,6 +136,14 @@
88136

89137
-keep class com.itsaky.androidide.treesitter.** { *; }
90138

139+
# Protobuf lite: the generated runtime resolves message fields by name via
140+
# reflection (the info string baked into newMessageInfo()), so shrinking a
141+
# "field with no direct bytecode reference" breaks it at runtime with a
142+
# NoSuchFieldException (observed on SyncMetaModels$SyncMeta.projectModelInfo_).
143+
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
144+
<fields>;
145+
}
146+
91147
# Retrofit 2
92148
-dontwarn retrofit2.**
93149
-keep class retrofit2.** { *; }
@@ -101,15 +157,19 @@
101157
-keep interface okhttp3.** { *; }
102158
-dontwarn okhttp3.**
103159

104-
# Stat uploader
105-
-keep class com.itsaky.androidide.stats.** { *; }
106-
107160
# Gson
108161
-keep class * extends com.google.gson.TypeAdapter
109162
-keep class * implements com.google.gson.TypeAdapterFactory
110163
-keep class * implements com.google.gson.JsonSerializer
111164
-keep class * implements com.google.gson.JsonDeserializer
112165

166+
# Gson model classes: nothing calls `new TemplatesIndex(...)` directly --
167+
# only gson.fromJson(..., TemplatesIndex::class.java) does, via reflection.
168+
# With no traceable constructor call, R8 strips the constructor and Gson's
169+
# runtime then reports the class as abstract ("Failed to load template
170+
# archive ... Abstract classes can't be instantiated!").
171+
-keep class com.itsaky.androidide.templates.impl.zip.** { *; }
172+
113173
-keepclassmembers,allowobfuscation class * {
114174
@com.google.gson.annotations.SerializedName <fields>;
115175
}
@@ -143,9 +203,18 @@
143203
-keep class com.itsaky.androidide.plugins.** { *; }
144204
-keep interface com.itsaky.androidide.plugins.** { *; }
145205

146-
## Initial rules to enable when R8 is shrinking to address exceptions
147-
#-keep class com.sun.tools.jdi.** { *; }
148-
#-keep class com.sun.jdi.** { *; }
206+
## ADFA-3604: JDI's SocketAttachingConnector/SocketListeningConnector are
207+
## loaded via ServiceLoader (META-INF/services), which R8 can't trace, so it
208+
## stripped their no-arg constructors. This surfaced as
209+
## "ServiceConfigurationError: Provider ... could not be instantiated" ->
210+
## "java.lang.Error: no Connectors loaded" from VirtualMachineManagerImpl,
211+
## which the app then reports to the user as a generic "Network access
212+
## error" (the debug-connect failure handler always appends a network
213+
## suggestion regardless of cause) even though this has nothing to do with
214+
## network permissions. This is exactly the exceptions these rules were
215+
## anticipating -- enabling them now that shrinking is genuinely on.
216+
-keep class com.sun.tools.jdi.** { *; }
217+
-keep class com.sun.jdi.** { *; }
149218

150219
## R8 Kotlin metadata workaround for Kotlin 2.3.0 compatibility
151220
## Suppresses D8 errors when parsing kotlin metadata for StopWatch inline functions

‎app/src/main/java/com/itsaky/androidide/fragments/output/BuildOutputFragment.kt‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import android.view.View
2121
import android.widget.LinearLayout
2222
import androidx.fragment.app.activityViewModels
2323
import androidx.lifecycle.lifecycleScope
24-
import com.blankj.utilcode.util.SizeUtils
2524
import com.itsaky.androidide.R
2625
import com.itsaky.androidide.databinding.LayoutLogFilterBarBinding
2726
import com.itsaky.androidide.editor.ui.EditorSearchLayout
2827
import com.itsaky.androidide.editor.ui.IDEEditor
2928
import com.itsaky.androidide.idetooltips.TooltipTag
3029
import com.itsaky.androidide.models.LogFilter
3130
import com.itsaky.androidide.utils.BasicBuildInfo
31+
import com.itsaky.androidide.utils.dpToPx
3232
import com.itsaky.androidide.utils.flashInfo
3333
import com.itsaky.androidide.viewmodel.BuildOutputViewModel
3434
import kotlinx.coroutines.Dispatchers
@@ -152,7 +152,7 @@ class BuildOutputFragment :
152152
val ed = editor ?: return
153153
ed.setLineNumberEnabled(enabled)
154154
// Zero the divider with the gutter, otherwise a stray 2dp rule remains.
155-
ed.setDividerWidth((if (enabled) SizeUtils.dp2px(2f) else 0).toFloat())
155+
ed.setDividerWidth((if (enabled) requireContext().dpToPx(2f) else 0).toFloat())
156156
}
157157

158158
override fun toggleFilterBar() {
@@ -201,7 +201,8 @@ class BuildOutputFragment :
201201
buildOutputViewModel.showTimestamps.value = enabled
202202
},
203203
onDeltasToggled = { enabled ->
204-
buildOutputViewModel.showDeltas.value = enabled},
204+
buildOutputViewModel.showDeltas.value = enabled
205+
},
205206
onVisibilityChanged = {
206207
updateEmptyState(
207208
isSourceEmpty = buildOutputViewModel.getCachedContentSnapshot().isEmpty(),
@@ -382,7 +383,7 @@ class BuildOutputFragment :
382383
if (visibleText.isEmpty()) {
383384
return
384385
}
385-
BuildOutputViewModel.filterLines(text, buildOutputViewModel.filterText.value)
386+
BuildOutputViewModel.filterLines(text, buildOutputViewModel.filterText.value)
386387

387388
withContext(Dispatchers.Main) {
388389
updateEmptyState(isSourceEmpty = false, isFilterActive = isFilterActive)

‎subprojects/kotlin-analysis-api/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212

1313
val ktAndroidRepo = "https://github.com/appdevforall/kotlin-android"
1414
val ktAndroidVersion = "2.3.255"
15-
val ktAndroidTag = "v$ktAndroidVersion-d4599b9"
15+
val ktAndroidTag = "v$ktAndroidVersion-4d3c8ea"
1616
val ktAndroidJarName = "analysis-api-standalone-embeddable-for-ide-$ktAndroidVersion-SNAPSHOT.jar"
1717

1818
externalAssets {
@@ -21,7 +21,7 @@ externalAssets {
2121
source =
2222
AssetSource.External(
2323
url = uri("$ktAndroidRepo/releases/download/$ktAndroidTag/$ktAndroidJarName"),
24-
sha256Checksum = "608263b39cf2297ae684981cd4da8194572d95178dda7623588ecd577461eeca",
24+
sha256Checksum = "418da363aaa6ebea3f234042cf91444de751bcf8264c4eb9cde38c763a79b3a5",
2525
)
2626
}
2727
}

0 commit comments

Comments
 (0)