oppia-android: [BUG]: Fix all Android lint failures.
Describe the bug
We would like to fix all the remaining lint issues on Oppia Android. There are currently 195 errors and 1009 warnings. Also, 38 checks are currently disabled.
We’d like to get rid of all these errors and then enable all the lint checks fully on CI (see https://github.com/oppia/oppia-android/issues/1742).
Steps To Reproduce
Run the following command from a terminal in a checked-out Oppia Android repo:
./gradlew :app:lint
Expected Behavior
Running the command above should not show any errors.
Screenshots/Videos
This is the first part of the error report:
Project Organization
This project can be divided into multiple parts. Please specify which part you want to take up and show a screenshot of a lint report with no errors for the corresponding issues in order to claim a part (and make a PR for it). Also, explain your general approach to fixing the errors for the part you claimed (don’t just suppress the errors).
The relevant parts are listed below:
- #5195
- #5186
- #5230
- VectorRaster
- #5273
- #5204
- ObsoleteLintCustomCheck
- DefaultLocale + OldTargetApi + UnknownIdInLayout + GradleDependency
- MissingTranslation + ExtraTranslation
- #5231
- #5272
- UnusedResources
- #5261
- MergeRootFrame
- #5194
- #5171
- #5182
- Explicitly unsuppress the following disabled checks and fix any violations: AppLinksAutoVerifyError, AppLinksAutoVerifyWarning, BackButton, ConvertToWebp, DalvikOverride
- Explicitly unsuppress the following disabled checks and fix any violations: DuplicateStrings, EasterEgg, FieldGetter, GoogleAppIndexingApiWarning, GoogleAppIndexingWarning
- Explicitly unsuppress the following disabled checks and fix any violations: IconExpectedSize, ImplicitSamInstance, KotlinPropertyAccess, LambdaLast, LockedOrientationActivity
- Explicitly unsuppress the following disabled checks and fix any violations: LogConditional, MangledCRLF, MinSdkTooLow, MissingRegistered, NegativeMargin
- Explicitly unsuppress the following disabled checks and fix any violations: NewerVersionAvailable, NoHardKeywords, NonResizeableActivity, PermissionImpliesUnsupportedChromeOsHardware, Registered
- Explicitly unsuppress the following disabled checks and fix any violations: RequiredSize, SelectableText, SourceLockedOrientationActivity, StopShip, SyntheticAccessor
- Explicitly unsuppress the following disabled checks and fix any violations: TypographyQuotes, UnknownNullness, UnpackedNativeCode, UnsupportedChromeOsCameraSystemFeature
- Explicitly unsuppress the following disabled checks and fix any violations: UnsupportedChromeOsHardware, UnusedIds, ValidActionsXml, WrongThreadInterprocedural
About this issue
- Original URL
- State: open
- Created 9 months ago
- Comments: 32 (2 by maintainers)
Commits related to this issue
- Fixed Issue #5169 All warnings in Internationalization — committed to Rd4dev/oppia-android by Rd4dev 9 months ago
- Fixed #5182 - All warnings in "Internationalization" (#5183) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanat... — committed to oppia/oppia-android by Rd4dev 9 months ago
- Fix #5204 - Inconsistent Layout Lint Warning (#5218) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation <!-... — committed to oppia/oppia-android by Rd4dev 8 months ago
- Fix: #5186: MissingDefaultResource + AppCompatCustomView + FragmentTagUsage (#5191) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Chec... — committed to oppia/oppia-android by theMr17 7 months ago
- Create firebase auth wrapper Refactor firebase auth wrapper Refactor dagger bindings for firestore dependencies Ensure firestore logs show in dev event logs view. Removed redundant bindings. Loca... — committed to oppia/oppia-android by adhiamboperes 7 months ago
Hi @adhiamboperes Another Approach: we can add checks using dataBindings for example:
Hi @aryanmishra29, an easy way to repro the issue is to navigate to
Code -> Inspect Code
.Then check on
Whole Project
and click onAnalyze
.Hi @adhiamboperes, I’ve found a solution of this issue:
RestrictedApi
class AppCompatCheckBoxBindingAdapters has an error:
The reason is using a private API. To resolve it, we can use:
Here is a screen of lint report Before
After
Hi @adhiamboperes,
I would like to continue to work on -
All warnings in "Usability:Typography", "Usability:Icons", and "Usability" categories
task.The issues can be categorized as:
Fix:
style="?android:attr/buttonBarButtonStyle"
to implement borderless buttons as suggested."OK"
for better consistency.tools:ignore="TypographyDashes"
where Unicode couldn’t be applied.12sp
, as recommended, from the previous size of 10sp.I have the code changes in my forked repository [Link1][Link 2] for your review and have attached before-and-after screenshots.
Screenshots
If this solution aligns with the project’s requirements, I’d appreciate it if you could assign the task to me so I can proceed with making a pull request.
Thank you!
Best regards, RD [Rama Devi]
Hi @BenHenning, I would like to work in this part. There is a compile-time error on line 231 in class ControlButtonsViewModel.
I can solve this error by:
using if-else operator. If API 26 and higher use java.util.Base64 class else use android.util.Base64 class
android.util.Base64 has encodeToString as equivalent of getEncoder().encode(args) it both Passing DEFAULT results in output that adheres to RFC 2045. So I can try to return right away:
return android.util.Base64.encodeToString(compressedMessage, 0)
Hi @adhiamboperes,
I am a new contributor to oppia-android and would like to start my contributions with the project. I’ve signed the CLA, filled out the survey form, and set up the environment locally. After some initial exploration, I believe I can assist with some lint issues.
I’d like to begin with the task related to
All warnings in "Internationalization"
While working on it locally, I encountered two types of issues:Fix:
string resource values
andpadding end values
.I have the code changes in my forked repository [Link] for your review and have attached before-and-after screenshots.
Screenshots:
If this solution aligns with the project’s requirements, I’d appreciate it if you could assign the task to me so I can proceed with making a pull request.
Thank you!
Best regards, RD [Rama Devi]
Hi @adhiamboperes, I would like to work on this next.
MissingDefaultResource
mainly has a single issue with a string which has different names in english and other translations. It can be easily fixed, by matching the name of that string in english and other translations.AppCompatCustomView
, it can be fixed by replacing the Normal views with AppCompat views<fragment/>
tags can be replaced with<androidx.fragment.app.FragmentContainerView/>
.Hi @adhiamboperes, I would like work on this part. Under this category, the warnings are mainly of 3 types.
Warning: Image without contentDescription. Fix: Add a
contentDescription
to each of thoseImageView
.Warning: ‘onTouch’ lambda should call ‘View#performClick’ when a click is detected Fix: Call
customView.performClick( )
.Warning: ‘clickable’ attribute found, please also add ‘focusable’. Fix: Set
android:focusable="false"
as it is a button.