Search code examples
android-studiointellij-idea

IndexNotReadyException when building the application


Writing an android application. It has no errors when I run it on an emulator. But when I tried to build it to an apk file to test on a device, I get the following error.

com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
    at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:853)
    at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:802)
    at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:786)
    at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:250)
    at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:238).......

I seen one similar case raised here which mentions to "Wait till indexing is complete."But I am not sure what I am doing to even interfere with any indexing.

Tried on different computers. Same problem. The only thing I did different before I got this error was to add a dependency at gradle(app) for a RingButton and added that RingButton class to the project to modify it to what I wanted. As I said it is working fine in emulator.

Just to test if that is indeed the isse, I deleted the class and removed the dependency but the issue is not resolved.


Solution

  • I was using Dropbox to constantly backup my project every now and then. So I would click my project and send to Dropbox. I was also instantly clicking run to run the app on my emulator at the same time. During this period, when I mouse over my Dropbox icon, there is an indication that it is "Indexing".

    Based on previous answer "Wait till indexing is complete", I can only assume this Dropbox indexing interfered somehow.

    Not exactly elegant but I copied each and every file in this project into a New Project and everything is working fine now and able to install the apk file. I didn't change anything so I believe there is some form of corruption in the old project.