Closed knutsoned closed 9 years ago
This is from my build.gradle:
apt {
arguments {
// figuring out the actual location for the Manifest turns out to be a monumental pain in the ass right now in gradle
// we're going to hard code the location of our manifest.... this will work until we have more than one of them!
androidManifestFile "${project.projectDir.absolutePath}/src/main/AndroidManifest.xml"
}
}
Thank you. I am now able to run the app on my device. I'm a little confused though. The instructions for setting up Transfuse say to start with an empty manifest since it will be populated by the framework. So, is src/main/AndroidManifest.xml rebuilt from scratch, or does this file become the base for each build, with the latest tags merged in?
Basically, if I remove an activity in the future, will its entry stay in this file until I manually remove it? I'd be happy to help find a better way to do this if it will just take some effort to set something up.
The manifest is generated, but it is only made from scratch if one does not exist. It will merge the transfuse managed stuff in with the non-transfuse managed stuff if one exists. It uses the tag attr to determine what is transfuse managed and what is not. If you remove a TF managed activity it should be removed from the manifest when you build...
FWIW, we check the generated manifest into source control as we do have some third party components that are not managed by transfuse. Plus it's nice to be able to watch the history of that file.
Is there any work that needs to be done to support different manifests for variants?
I believe there is... probably some work in gradle (which may be done already) in addition to some in transfuse.. fortunately we do not yet have a need for that so I haven't investigated.
If the changes per variant are of the right type, it's possible that it can be entirely handled with the gradle manifest merging capability that is live already.. but like I said, I don't have direct experience with it.
Just as an aside, if you find that a project won't build (default activity not found) with Android Studio that already uses Transfuse, try renaming the manifest (AndroidManifest-old.xml), do a build (it will fail), and then undo your rename and do another build... Then it should magically build, I'm not really sure why this fixed it, I'm assuming it triggered Transfuse to do something it needed to do.
@DasCody, that's a strange one. Do you have any other errors that may be useful?
@johncarl81 I checked out an existing application from source control that was using this framework. Upon trying to do a build I received a popup letting me know the default activity wasn't found (default activity not found). In the AndroidManifest file the default activity (and all the other activities) didn't exist. I spent sometime trying to fix it manually, but then I noticed that Transfuse manages the AndroidManifest, so I renamed it to AndroidManifest-old.xml thinking it would generate a new one for me (from what I read it looked like Transfuse would do this), it ended up resulting in a build error though. I renamed it back to AndroidManifest.xml, and then tried to build again and it worked.
Sorry that I can't give you more information. I've never had much interest in using a framework like this one (it looks useful though) so I'm not really up to speed with everything Transfuse does, from what I could tell though, it seems like it manages the AndroidManifest and that's where the error seemed to be stemming from.
Ah, ok, thanks for the context... Are you using Gradle as well?
Yeah it's going through Gradle, the manifest file is being declared there as well, same as the comment above from dbachelder.
Alright. Strange that you had to kickstart it in the way that you did. As always, let me/us know if you have any other issues.
Using the latest Android Studio bundle from Google and following instructions here http://stackoverflow.com/a/17765732/4267732 results in an app that builds but can not be run from within AS. A "Default Activity not found" error prevents execution.
The gradle example features this generated file which is checked in https://github.com/johncarl81/transfuse/blob/master/examples/gradle/GradleTransfuse/src/main/AndroidManifest.xml
Because the generated file is checked in, the example app runs from AS, but this seems incorrect unless I am missing something.
The SO thread suggests adding a folder like source/apt_generated/debug but this no longer exists with more recent versions of the android-apt plugin. Can the gradle example be updated so it works with AS 0.8+ and android-apt 1.4+ without a generated manifest checked in where the empty one normally lives? In other words, how does build.gradle need to be modified so it will pick up the file generated by apt?