Skip to content Skip to sidebar Skip to footer

How To Manually Add Gradle Module To Android Project?

I'm working on a project that was created before Gradle became the build system for Android development (LibreOffice Viewer for Android). When the project was migrated to Gradle, i

Solution 1:

It is definitely possible to do this manually, as I did it for literally hundreds of book sample apps.

You listed these steps:

  • Create a new folder for the module (here, I'll call it app)
  • Create a new build.gradle file within it
  • Move the appropriate files

You also need to:

  • Add your module to settings.gradle, creating that file if needed (or copying it from an existing Android Studio project)

  • Have your app/build.gradle correctly reflect the locations of the moved files, which could include removing stuff like main.assets.srcDirs, if your files are now all in standard locations (the way that you would find in a newly-created Android Studio project)

  • Add a new project-level build.gradle file, probably just copied from some standard Android Studio project

In terms of Android Studio itself, I strongly recommend doing this project reorganization outside of Studio. Then, delete generated Studio items (all .iml files, .idea/ subdirectory, build/ directories), and finally import the project back into Studio.

Post a Comment for "How To Manually Add Gradle Module To Android Project?"