'Can't install expo modules on react-native-cli project

I have a react native project made with react-native-cli. To add expo modules, I did npx install-expo-modules which makes changes to MainActivity.java, MainApplication.java, and settings.gradle according to their official document. After that, I kept getting

Execution failed for task ':app:compileDebugJavaWithJavac'

specifically

package expo.modules does not exist

and

error: cannot find symbol.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source