Home > Back-end >  How can I specify location of AndroidManifest.xml?
How can I specify location of AndroidManifest.xml?

Time:12-30

I'm porting a module from Eclipse to Android Studio/Gradle, and need to specify the locations of my sources, resources, and manifest:

sourceSets {
    main {
        manifest {
            srcFile './AndroidManifest.xml'
        }
        java {
            srcDirs = ["src"]
        }
        resources {
            srcDirs = ["resource"]
        }
    }
}       

Android Studio/Gradle seems perfectly happy with my java and resources entries, but balks at my manifest entry:

No signature of method: build_b4wnchd9ct4a5qt388vbbtbpz.sourceSets() is applicable for argument types: (build_b4wnchd9ct4a5qt388vbbtbpz$_run_closure2) values: [build_b4wnchd9ct4a5qt388vbbtbpz$_run_closure2@35290d54]

All of my googling and searching SO suggests that this should have worked.

Arctic Fox, 2020.3.1. Not sure which version of Gradle came with it.

CodePudding user response:

Ahh, figured it out. Leaving here in case someone else has the same question.

Add an android.sourceSets.manifest.srcFile entry to your module's build.gradle file:

android {
    ...
    sourceSets {
        main {
            manifest {
                srcFile './AndroidManifest.xml'
            }
        }
    }
}

or simply:

android {
    ...
    sourceSets.main.manifest.srcFile './AndroidManifest.xml'
}

My biggest mistake was not putting the sourceSets directive inside the android directive.

  • Related