Gradle Incremental Java build fails with "cannot find Symbol error"

Build is failing when I did a change in Java file

Android Gradle Plugin: 3.2.1
Gradle Version: 4.6

Please find the snapshot of error below:

17:58:31.131 [ERROR] [system.err] symbol: class FragmentNavigationManager
17:58:31.132 [ERROR] [system.err] location: package com.microsoft.office.officemobile.FragmentManagerInfra
17:58:31.138 [ERROR] [system.err] D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ActionsTab\ActionsAdapter.java:45: error: cannot find symbol
17:58:31.138 [ERROR] [system.err] import com.microsoft.office.officemobile.KaizalaPhoneauth.KaizalaPhoneAuthManager;

I checked the undefined symbols are present inside file FragmentNavigationManager.java file inside the sources.

Using debug logs, I found the class file FragmentNavigationManager.class is getting deleted before doing java build

gradle: 17:58:28.630 [DEBUG] [org.gradle.api.internal.file.delete.Deleter] Deleting d:\office\build\droidarm\ship\officemobile\android\java\intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobile\FragmentManagerInfra\FragmentNavigationManager.class

After deletion of above class, while doing Java incremental build, FragmentNavigationManager.java should be passed as an input for javac, but it is not happening, which is causing undefined symbol issue. Clean build working fine

Arguments passed to Java compiler

gradle: 17:58:29.155 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -source 1.8 -target 1.8 -d d:\office\build\droidarm\ship\officemobile\android\java\intermediates\javac\release\compileReleaseJavaWithJavac\classes -encoding UTF-8 -bootclasspath d:\office\build\droidarm\ship\officemobile\android\java\intermediates\javac\release\compileReleaseJavaWithJavac\classes D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Actions\ConversionToDocHelper.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Actions\LensScanQRCodeFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Actions\QrCodeResultDialogFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Actions\QRCodeTeachingDialog.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ActionsTab\ActionsAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ActionsTab\ActionsFeatureManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\clipboard\ExcelClipContentProvider.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\clipboard\PowerPointClipContentProvider.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\clipboard\WordClipContentProvider.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\ControlHostFactory.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\ControlHostManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\IControlHostCallbackListener.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\LensControl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\PdfControl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ControlHost\WXPControl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateDialogFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateDocumentRecycleViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateDocumentSubsectionRecycleViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateDocumentTabDialogFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreatePdfBottomSheetDialog.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateTabBottomSheetDialog.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\CreateWXPBottomSheetDialog.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\CreateTab\DocumentSingleItemRowHolder.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\AccountDetailsManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\AccountsInfoManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\ActionsFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\DashboardInitializationHelper.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\HomeTabFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\KaizalaPhoneAuthFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\OfficeMobileSendFeedbackHandler.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\SendFeedbackActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\SendFeedbackFormFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\SendFeedbackViewFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\dashboard\SettingsLandingManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\DefaultBootHandler.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\DocumentToPdf\DocumentToPdfSessionHolder.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FileActivationBootManagerUser.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\FilePickerManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\OpenFilePicker.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\SaveAsPicker.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\SelectFilePicker.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\SelectFolderPicker.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FilePicker\selectpicker\SelectPickerView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\filetransfer\FileTransferActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\filetransfer\FileTransferListAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\filetransfer\FileTransferManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\filetransfer\FileTransferViewModel.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FirstRunExperience.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\FreCardsDismissalManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\filelist\recent\RecentListView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\filelist\recent\RecentListViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\GetToContentView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\GetToJniProxy.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\GetToManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\DocumentsTab.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\DocumentsTabView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\MediaTab.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\MediaTabView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\NotesTab.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\getto\tab\NotesTabView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\GetToUser\CFileListInteractionManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\GetToUser\CGetToUser.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\helpers\FeatureGateUtils.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\helpers\OfficeMobileResetTaskListener.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\IOfficeMobileBootManagerUser.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensImageToWordActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\IPreviewerCloudLocalStrategy.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensActivityLifecycleListenerForPreview.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensCameraFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensCoreEventListenerForPreview.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensHelper.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensImageToPdfFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensPreviewFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensScanToPdfFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensScanToWordFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\LensTableAndTextActionFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\mediadata\LensMediaUtils.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\mediadata\MediaDatabaseRWUtil.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\mediadata\MediaDataRWUtil.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\mediadata\MediaSessionDataProvider.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\mediadata\ThumbnailCache.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\MediaTabUI\MediaSearchSessionRecyclerViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\MediaTabUI\MediaSessionGridViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\MediaTabUI\MediaSessionRecyclerViewAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\PreviewerCloudStrategyImpl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\PreviewerLocalStrategyImpl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\LensSDK\PreviewerMediaTabStrategyImpl.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\MultiProcessActivityLifeCycleCallbacks.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\MultiProcessModeUtils.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileActivationEvents.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileApplication.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileApplicationDelegate.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileBootManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileDocsUIElementEventHandler.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileExcelApplicationDelegate.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobilePPTApplicationDelegate.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\OfficeMobileWordApplicationDelegate.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\OfficeMobilePdfActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfActivityViewModel.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfConsumptionView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfEditView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfFileOpeningView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfNewSignaturePanelView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfOptionsBottomSheetDialogFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfRenameAction.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfSaveAsAction.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfSearchView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfSignatureBottomSheetDialogFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfSignatureEditView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\Pdf\PdfThumbnailView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\FileTransferStatusAdapter.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyAdvertisersBottomSheet.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyConnectionManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyDialogManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyFileTransferStatusFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyModel.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyScanningForPeopleFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbySendReceiveFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyUtils.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ShareNearby\ShareNearbyViewModel.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\StickyNotes\EditNoteActivity.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\StickyNotes\OfficeMobileEditNoteFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\StickyNotes\OfficeMobileNotesListFragment.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\StickyNotes\StickyNotesCameraFlow.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\StickyNotes\StickyNotesManager.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\views\DashboardBootView.java D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\warmup\DefaultWarmUpStrategy.java

I found the issue
The source file path is: src\com\microsoft\office\officemobile\fragmentmanagerinfra\FragmentNavigationManager.java

Generated Class file: intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobile\FragmentManagerInfra\FragmentNavigationManager.class

There is a case mismatch in directory name at source path and generated class path, which is causing the issue. Source path has fragmentnavigationmanager instead of FragmentNavigationManager

I found that the package name is: com.microsoft.office.officemobile.FragmentManagerInfra.FragmentNavigationManager. Changing directory name to match the package name at the source path resolves the issue

Is this expected, as full build is working fine and incremental Gradle build is only failing?
Working on Windows 10

Ultimately you’ve got a mismatch between your package name and your folder name. But yes, it seems you’ve found a little bug that won’t affect many people (since IDEs generate source folders based on packages). I’m unsure if the bug is in Gradle or javac.

I’m guessing the bug relates to:

  • Keys used during caching and up to date checking are case sensitive
  • Windows file paths are case insensitive

I wonder how this would behave on a Unix like OS as the file system is case sensitive. My guess is Unix will behave differently to Windows on this occasion

Ideally java package names should be lowercase. If it were me I’d rename the package to lowercase and have the folder name lowercase too.

Thanks @Lance
Renaming package/folder name is the only option I have
Although this is a cumbersome task, because of the very large code base I have

this is a cumbersome task, because of the very large code base

I often use gradle scripts to do tasks like this… Gradle has nice file API’s for iterating / filtering / mutating trees of files

@Lance I am using Gradle version 4.6.0. Do you see any chance of getting this fixed in later versions?

Fixed? I’m guessing a fix in Gradle would be a nicer error message.

Ultimately your folder names need to match your package names. You can write a script to help fix your local filesystem so that folders match packages