Search code examples
androidandroid-studioandroid-ndk

Android Studio cannot be configured correctly with a multi module project


I have cloned a project from GitHub and am trying to configure the Android component with Android Studio and the IDE does not work properly. The Gradle button does not show up, I many references are unresolved, my AVD is not recognized and the android module does not even show up in the project.

I configured all dependencies, tried setting folders are sources, creating new modules, restarting IDE but nothing works. I need Android Studio to actually recognize the project and show me the relevant options. This is a C++ project by the way so I am using the NDK to set it up.

You can see from highlighted areas of the screenshot that the android module does not show up and I can't run the "app" as I normally would. There is only a directory name there.

enter image description here


Solution

  • Looking at the root of the organicmaps githug project:

    enter image description here

    There is not a settings.gradle, therefore it won't import correctly as a Gradle (multi-module) project in AndroidStudio.

    I can see in this folder organicmaps/android there is a build.gradle and a gradlew and a gradle.properties, so likely this is the "root" of the AndroidStudio project.

    enter image description here

    Try opening this folder as the root of your project. As in close AndroidStudio and create a new project using the folder: organicmaps/android instead of organicmaps.


    Based on your comment.

    It works for me, I opened the android folder in AndroidStudio and it loads as a Gradle project.

    enter image description here

    However it does then fail to sync, you have to comment out the code they have for making a release & create an empty secure.properties file, because it wants the release credentials and you don't have them.

    enter image description here

    After that, you have code completion and the files on your classpath. There is still an NDK problem, not in my knowledge how to deal with that sorry.

    ^ Did a bit more exploring. After the above, I went up to the root folder and ran:

    ./configure.sh (Figured it sets stuff up, got it from here.)

    Then found all the instructions in /docs/, if you read /docs/INSTALL.md it has specific Android instructions, and says to import like I said above.

    I then ran

    ./gradlew webDebug

    enter image description here

    and we're up and running :-)