Why Can't I Edit My Manifest In Android Studio?
While working on an Android app, you go to run your project, and bam, you get a build error related to something in your manifest. You already closed that tab in Android Studio, so you double-click on the error, which opens an editor on a manifest, pointing out the offending line. You make the fix. Part of you wonders why Android Studio is showing all sorts of legitimate stuff in the manifest as errors, but, hey, it’s Android Studio — it acts oddly from time to time.
You go to run your project, and bam, you get a build error related to something in your manifest. It turns out that it is the problem you just fixed. So, you double-click on the error, and you notice that your fix from a moment ago went away.
At this point, there are two possibilities:
-
You have found a glitch in the Matrix.
-
You are using Android Studio, at least through v2.0.0, and you are encountering this bug that I filed a report on 15 months ago.
What is happening is that double-clicking the error is opening up a tab
on a manifest. It is the wrong manifest. Rather than the
AndroidManifest.xml
file from somewhere in src/
, it is a generated
manifest from somewhere in build/
. This generated manifest blends in
not only your module’s manifest, but entries from the manifests of
modules and other dependencies (such as
their <uses-permission>
elements),
your module’s build.gradle
file, and so on. Changes you make here will
be obliterated on your next build.
When editing a manifest, make sure that it is the right manifest.