Today I helped a student who was seeing some strange behavior from Android Studio. The IDE appeared to be mostly working, but compilation failed with errors about being unable find several items that all happened to be provided by a library.
Opening the project produced a "Migrate to Gradle" suggestion stating that "this project does not use the Gradle build system." Accordingly, there was no File | Sync Project with Gradle Files menu item. The project had been created as a Gradle project. I was shown screenshots that confirmed the existence and contents of all expected build.gradle files, which was very confusing because the migration suggestion appeared even after clearing all caches I could think of.
Staring very intently at the screen eventually revealed a subtle problem: the parent directory of the project had been opened, not the project itself. Since there was no build.gradle in the opened root directory, Android Studio rightfully did not consider it a Gradle project, but allowed setting the Android SDK manually (which is what the student must have done to be able to attempt compilation). Opening the correct location in the directory hierarchy fixed the problem.
No comments:
Post a Comment