Status Update
Comments
co...@protonmail.com <co...@protonmail.com> #2
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
ch...@google.com <ch...@google.com> #3
1. Android Studio version and OS type and version
2. Screenshots or videos of the issue
3. idea.log file (select Help > Show Log in Finder / Explorer)
4. Thread dumps if the issue is a freezing or non-responding UI.
For more information on what’s needed and how to obtain this information please read the guide at
tn...@google.com <tn...@google.com> #4
We don't need the information listed above, that's pretty standard verbiage from the triage bug front end for all Studio issues.
However, that message (Unexpected failure) is normally followed by an actual stacktrace summary which pinpoints the problem. Here's a sample message which is emitted during one of lint's unit tests for this (which deliberately crashes):
src/test/pkg/Foo.java: Error: Unexpected failure during lint analysis of Foo.java (this is a bug in lint or one of the libraries it depends on)
Message: / by zero
The crash seems to involve the detector com.android.tools.lint.client.api.LintDriverCrashTest$CrashingDetector.
You can try disabling it with something like this:
android {
lintOptions {
disable "_TestCrash"
}
}
Stack: ArithmeticException:LintDriverCrashTest$CrashingDetector$createUastHandler$1.visitFile(LintDriverCrashTest.kt:178)
←UElementVisitor$DispatchPsiVisitor.visitFile(UElementVisitor.kt:707)←UFile$DefaultImpls.accept(UFile.kt:80)
←JavaUFile.accept(JavaUFile.kt:11)←UElementVisitor$visitFile$4.run(UElementVisitor.kt:292)
←LintClient.runReadAction(LintClient.kt:1770)←TestLintClient.runReadAction(TestLintClient.java:893)
←LintDriver$LintClientWrapper.runReadAction(LintDriver.kt:2615) [LintError]
1 errors, 0 warnings
Do you have similar output?
co...@protonmail.com <co...@protonmail.com> #5
Here is the full output
mac16:rollertoaster coltonidle$ ./gradlew app:lintFreeDebug
> Configure project :
The Dependency Analysis plugin is only known to work with versions of AGP between 3.5.4 and 7.0.0-alpha05. You are using 7.1.0-alpha01. Proceed at your own risk.
> Configure project :app
WARNING:API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see TBD.
To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
> Task :app:lintAnalyzeFreeDebug
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.10/3f4af7aff21c4ec46e3cdd645639d0a63a68d3d0/kotlin-stdlib-jdk8-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.4.31/63db9d66c3d20f7b8f66196e7ba86969daae8b8a/kotlin-reflect-1.4.31.jar (version 1.4)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Consider providing an explicit dependency on kotlin-reflect 1.5 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.10/3f4af7aff21c4ec46e3cdd645639d0a63a68d3d0/kotlin-stdlib-jdk8-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20181211/216c2e14b070f334479d800987affe4054cd563f/trove4j-1.0.20181211.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.com-intellij/intellij-core/30.1.0-alpha01/29f6bd46f757e6915c7eb6cc7d760f3d2a4bd089/intellij-core-30.1.0-alpha01.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.org-jetbrains/uast/30.1.0-alpha01/deb7df8d140b1dea70341eba7fad43e763fb70d5/uast-30.1.0-alpha01.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Scanning app: .............................
Scanning app (Phase 2): .....................
> Task :app:lintFreeDebug FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.10/3f4af7aff21c4ec46e3cdd645639d0a63a68d3d0/kotlin-stdlib-jdk8-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.4.31/63db9d66c3d20f7b8f66196e7ba86969daae8b8a/kotlin-reflect-1.4.31.jar (version 1.4)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
/Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Consider providing an explicit dependency on kotlin-reflect 1.5 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.10/3f4af7aff21c4ec46e3cdd645639d0a63a68d3d0/kotlin-stdlib-jdk8-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20181211/216c2e14b070f334479d800987affe4054cd563f/trove4j-1.0.20181211.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.com-intellij/intellij-core/30.1.0-alpha01/29f6bd46f757e6915c7eb6cc7d760f3d2a4bd089/intellij-core-30.1.0-alpha01.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Custom lint rule jar /Users/coltonidle/.gradle/caches/modules-2/files-2.1/com.android.tools.external.org-jetbrains/uast/30.1.0-alpha01/deb7df8d140b1dea70341eba7fad43e763fb70d5/uast-30.1.0-alpha01.jar does not contain a valid registry manifest key (Lint-Registry-v2).
Either the custom jar is invalid, or it uses an outdated API not supported this lint client
Wrote HTML report to file:///Users/coltonidle/Dev/Projects/rollertoaster/app/build/reports/lint-results-freeDebug.html
Lint found 8 errors. First failure:
/Users/coltonidle/Dev/Projects/rollertoaster/app/src/free/java/com/rollertoaster/app/MockNetwork.kt: Error: Unexpected failure during lint analysis of MockNetwork.kt (this is a bug in lint or one of the libraries it depends on)
The crash seems to involve the detector androidx.fragment.lint.OnCreateDialogIncorrectCallbackDetector.
You can try disabling it with something like this:
android {
lintOptions {
disable "DialogFragmentCallbacksDetector"
}
}
Stack: NullPointerException:OnCreateDialogIncorrectCallbackDetector$UastHandler.visitClass(OnCreateDialogIncorrectCallbackDetector.kt:78)←UElementVisitor$DispatchPsiVisitor.visitClass(UElementVisitor.kt:597)←UElementVisitor$DelegatingPsiVisitor.visitClass(UElementVisitor.kt:1156)←AbstractKotlinUClass.accept(KotlinUClass.kt:63)←ImplementationUtilsKt.acceptList(implementationUtils.kt:23)←UFile$DefaultImpls.accept(UFile.kt:83)←KotlinUFile.accept(KotlinUFile.kt:31)←UElementVisitor$visitFile$3.run(UElementVisitor.kt:281)
You can run with --stacktrace or set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout. [LintError]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintFreeDebug'.
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintTask$AndroidLintLauncherWorkAction
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintWorkAction
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
58 actionable tasks: 3 executed, 9 from cache, 46 up-to-date
co...@protonmail.com <co...@protonmail.com> #6
If I run the same command above but with --stacktrace I get this
The crash seems to involve the detector androidx.fragment.lint.OnCreateDialogIncorrectCallbackDetector.
You can try disabling it with something like this:
android {
lintOptions {
disable "DialogFragmentCallbacksDetector"
}
}
Stack: NullPointerException:OnCreateDialogIncorrectCallbackDetector$UastHandler.visitClass(OnCreateDialogIncorrectCallbackDetector.kt:78)←UElementVisitor$DispatchPsiVisitor.visitClass(UElementVisitor.kt:597)←UElementVisitor$DelegatingPsiVisitor.visitClass(UElementVisitor.kt:1156)←AbstractKotlinUClass.accept(KotlinUClass.kt:63)←ImplementationUtilsKt.acceptList(implementationUtils.kt:23)←UFile$DefaultImpls.accept(UFile.kt:83)←KotlinUFile.accept(KotlinUFile.kt:31)←UElementVisitor$visitFile$3.run(UElementVisitor.kt:281) [LintError]
tn...@google.com <tn...@google.com> #7
Thanks! This looks like it's a bug in one of the AndroidX-bundled lint checks; it looks like the problem is with the unsafe null call:
Reassigning to AndroidX for triage.
il...@google.com <il...@google.com> #8
Can you attach a sample project or enough code to reproduce this issue?
co...@protonmail.com <co...@protonmail.com> #9
I don't have a sample project, but the error points to this file seemingly?
package com.rollertoaster.app
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.RecordedRequest
val MY_DISPATCHER: Dispatcher =
object : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
return MockResponse().setResponseCode(404)
}
}
Some more info here:
But besides that I don't have a repo that shows this publicly available.
co...@protonmail.com <co...@protonmail.com> #10
This is an unrelated issue, but Tor says "Methods aren't guaranteed to have a surrounding class so probably safest to use the ?. operator..." and so maybe that's what has to be done in this lint check as well?
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 0a9efa914d322810f8dc8d9ba06e79d164c8892d
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jun 09 13:01:36 2021
Fix lint crashes on kotlin top level properties
We need to handle cases where kotlin functions don't have a surrounding
class.
This change allows the surrounding class to be null and in that case we
just skip the check.
RelNote: "The `OnCreateDialogIncorrectCallback` lint check will no
longer crash when declaring a top level variable."
Test: kotlin anonymous object test
Bug: 189967522
Change-Id: I62de88c344cee0cb9deda26c9e5fc27247cf2d95
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/OnCreateDialogIncorrectCallbackDetector.kt
M fragment/fragment-lint/src/test/java/androidx/fragment/lint/OnCreateDialogIncorrectCallbackDetectorTest.kt
il...@google.com <il...@google.com> #12
We've improved this lint check and the updated check will be available in Fragment 1.4.0-alpha03.
co...@protonmail.com <co...@protonmail.com> #13
Looking forward to it. Thanks!
de...@gmail.com <de...@gmail.com> #14
```
../../src/main/java/com/sample/app/App.kt: Unexpected failure during lint analysis of App.kt (this is a bug in lint or one of the libraries it depends on)
Message: class androidx.fragment.lint.OnCreateDialogIncorrectCallbackDetector$UastHandler tried to access protected method 'org.jetbrains.kotlin.psi.KtClassOrObject org.jetbrains.uast.kotlin.KotlinUClass.getKtClass()' (androidx.fragment.lint.OnCreateDialogIncorrectCallbackDetector$UastHandler is in unnamed module of loader com.intellij.util.lang.UrlClassLoader @10f53730; org.jetbrains.uast.kotlin.KotlinUClass is in unnamed module of loader java.net.URLClassLoader @4489af75)
The crash seems to involve the detector androidx.fragment.lint.OnCreateDialogIncorrectCallbackDetector.
You can try disabling it with something like this:
android {
lint {
disable "DialogFragmentCallbacksDetector"
}
}
Stack: IllegalAccessError:OnCreateDialogIncorrectCallbackDetector$UastHandler.visitClass(OnCreateDialogIncorrectCallbackDetector.kt:78)
←UElementVisitor$DispatchPsiVisitor.visitClass(UElementVisitor.kt:553)
←UElementVisitor$DelegatingPsiVisitor.visitClass(UElementVisitor.kt:1162)
←AbstractKotlinUClass.accept(AbstractKotlinUClass.kt:43)
←ImplementationUtilsKt.acceptList(implementationUtils.kt:29)
```
AGP 7.4.0-alpha03
Kotlin 1.6.20-M1
de...@gmail.com <de...@gmail.com> #15
de...@gmail.com <de...@gmail.com> #16
de...@gmail.com <de...@gmail.com> #17
co...@protonmail.com <co...@protonmail.com> #18
Are all of your deps up to date? This problem was fixed for me.
Description
Updated to compose beta08 and kotlin 1.5.10. Running lint gives me a few errors like this now:
Error: Unexpected failure during lint analysis of MyCustomClass.kt (this is a bug in lint or one of the libraries it depends on)