Status Update
Comments
uc...@google.com <uc...@google.com>
tn...@google.com <tn...@google.com> #2
Mike, any idea what this could be? As far as I can tell the lint side of this (LintBatchAnalytics) is doing the right thing but I'm not sure if there's some initialization it's missing (though it hasn't changed for several years).
du...@google.com <du...@google.com> #3
I'm hitting this as well. Attached is a project that reproduces the problems on my end, with HEAD around yesterday.
cm...@google.com <cm...@google.com> #4
This only throws if system property idea.is.internal is set, I wonder if something changed on
If that's the case we have two bugs: Studio injecting extra system properties and Analytics being silently broken in lint.
(I can repro with ./gradlew -Didea.is.internal=true clean lint
)
tn...@google.com <tn...@google.com> #5
Wow. Here's AnalyticsSettings.kt:
private fun ensureInitialized() {
if (!initialized && java.lang.Boolean.getBoolean("idea.is.internal")) {
// Android Studio Developers: If you hit this exception, you're trying to find out the status
// of AnalyticsSettings before the system has been initialized. Please reach out to the owners
// of this code to figure out how best to do these checks instead of getting null values.
throw RuntimeException("call to AnalyticsSettings before initialization")
}
}
So yes -- there's problem an issue with initialization here that went unnoticed because we don't set that system property from the command line tools during development -- only from Studio.
I'll take a look to see what's happening here. In the past I think lint relied on the setup being performed by AGP itself. I would think this would continue to work when lint is running in process?
cm...@google.com <cm...@google.com> #6
I may have broken this since AGP 7.0 if that's the case - as lint is now in a fully isolated classloader and so doesn't share the usage tracker static state with AGP This also means that lint cli never would write usage data either
tn...@google.com <tn...@google.com> #7
Do you know where the Gradle setup of the usage tracker is? Or the Studio one? I tried to find-usage my way to the initialization point but didn't succeed.
tn...@google.com <tn...@google.com> #8
Found AndroidStudioInitializer#setupAnalytics which has a lot of useful pointers.
(Btw I tried searching for UsageTracker.version in the tools/ IDE setup and didn't find anything; the setup is pretty broken in that project for me. I thought it was just the PSI stuff, but the analytics stuff also shows up as broken. For example, opening up LintBatchAnalytics -- that file has unresolved references into analytics. Is this working for anyone else?)
cm...@google.com <cm...@google.com> #9
Gradle's is here
We should check that it's ok to run twice in one process too (java file locking can be problematic within the same jvm in different classloaders)
cm...@google.com <cm...@google.com> #10
(It's expected that the analytics source files won't be able to find uses as from the tools-gradle idea setup those are now prebuilt by bazel. The search works if you find the binary UsageTracker. Hopefully soon those sources will be gone entirely so it's not confusing)
tn...@google.com <tn...@google.com> #11
What I meant is that I get errors like this:
cm...@google.com <cm...@google.com> #12
That example resolves for me - you might need to 'Load gradle changes' (the analytics-library has changed very recently to be a prebuilt)
tn...@google.com <tn...@google.com> #13
Turns out this stuff was already tested:
However, that test does not trigger this scenario because the test itself explicitly initializes analytics testing support (AnalyticsSettings.setInstanceForTest(analyticsSettings) etc).
So now I'm sitting here thinking how I would actually test this without using the test support and without making the test pollute real analytics. Does AGP have a solution for this? Or is manual testing adequate? (I did verify that with my upcoming CL .trk files are spooled.)
cm...@google.com <cm...@google.com> #14
AGP has its own wrapper for testing purposes that's driven by an injected gradle property (StringOption.PROFILE_OUTPUT_DIR), so that probably doesn't help here
jv...@google.com <jv...@google.com> #15
tn...@google.com <tn...@google.com> #16
There were tests using TestUsageTracker -- and those tests were passing because the test setup explicitly initializes the AnalyticsSettings.
But when lint was running (not under usage tracking tests), it was not initializing analytics (because it was relying on AGP setup to already have done that). This was silently broken because the "hey you're not initialized" error only shows up if somebody happens to have set idea.is.internal. There are pending CLs now to fix this.
jv...@google.com <jv...@google.com> #17
tn...@google.com <tn...@google.com> #18
(And yeah I agree with that!)
sp...@google.com <sp...@google.com> #19
I'm blocked by this issue.
sp...@google.com <sp...@google.com> #20
What pending CLs are supposed to fix this issue?
tn...@google.com <tn...@google.com> #21
The CLs are
Sergey, to workaround this, update your tools/adt/idea/emulator/screen-sharing-agent/app/build.gradle to contain
android {
lintOptions {
checkReleaseBuilds false
}
}
(and explicitly run lint as part of development; the vital lint checks run implicitly as part of assemble is a small subset).
(And I'm assuming you're running your Gradle command from within a Studio terminal such that idea.is.internal is set; you can also just make sure that is unset before your run.)
gi...@google.com <gi...@google.com> #23
Note: the posted work around works for me but it seems like the root cause is still an issue.
Attaching the project I used (note the project in its current state contains the work around)
The issue was encountered while running the benchmark test
tn...@google.com <tn...@google.com> #24
Are the line numbers in the exception different?
tn...@google.com <tn...@google.com> #25
(and what gradle target should I run to reproduce this?)
tn...@google.com <tn...@google.com> #26
Actually I see that in the attached project you're using AGP 7.0.0. Note that this fix is in AGP, not in Studio, so it's expected that you would get this error until you update the AGP version to one containing this fix, e.g. 7.2.0-alpha02.
sp...@google.com <sp...@google.com> #27
tn...@google.com <tn...@google.com> #28
No - this is pulling in a bunch of new code; too risky for 7.0 patch. We could simply go and remove the assertion throw in 7.0. But this bug should not affect external users since it only happens if idea.is.internal is set, which is a flag which should only be set by Studio (and IntelliJ) developers.
pa...@gmail.com <pa...@gmail.com> #29
I'm seeing this in Bumblebee stable. Does this mean that I can't use AGP 7.0 and 7.1 with Bumblebee?
I'm using idea.is.internal=true
to get PSI utilities for developing Detekt / Lint checks.
I do not want to disable lintVital, but I'll happily disable usage tracking, just don't know how; it looks like this lint -> UsageTracker code is unconditional.
I tried Settings > Data Sharing which set ~/.android/analytics.settings
to "hasOptedIn":false
, but it still fails.
Description
Build: AI-211.7628.21.2111.7545178, 202107131427,
AI-211.7628.21.2111.7545178, JRE 11.0.10+0-b96-7249189x64 JetBrains s.r.o., OS Linux(amd64) v5.10.40-1rodete2-amd64, screens 2560.0x1440.0, 1920.0x1200.0
AS: Bumblebee | 2021.1.1 Canary 4; Kotlin plugin: 211-1.5.20-release-284-AS7442.40; Android Gradle Plugin: 7.1.0-alpha04; Gradle: 7.1; Gradle JDK: version 11.0.10; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: (not found)
IMPORTANT: Please readhttps://developer.android.com/studio/report-bugs.html carefully and supply all required information.
Trying to run macrobenchmark in a trivial sample from within studio, seeing the following exception (project attached).
Note - this does not reproduce when running
./gradlew app:lintVitalAnalyzeBenchmark
from commandline.