I have created an Android project and set it as a library project in order to support a free and paid version of the App. The library project is set as a "...base" project and actually the paid version simply calls the base app including its Main Activity.

I need to make some changes to limit the Free version and I can easily override layout resources, but I'd like to know the simplest way to extend/override some of the Activities. Ideally, what I'd like to do is only subclass Activities where changes which limit functionality are required, but I'm hitting a few problems. My activities redirect to other activities within the App navigation and I'm finding that the error below is being generated:

03-11 13:54:10.068: E/AndroidRuntime(21264): android.content.ActivityNotFoundException: Unable to find explicit activity class {package.free/package.base.MainActivity}; have you declared this activity in your AndroidManifest.xml?

Obviously, I can add these to the manifest or I can abstract the redirects, but the 2nd option means that I need to subclass anything that can trigger a redirect or anything which can be the target of a redirect. Is there a simpler way?

有帮助吗?

解决方案

I managed to get this all working as I wanted. It does mean you need to be quite specific with projects which are using a library project in terms of which object you want to instantiate (and the activities or fragments that are declared in the manifest). I posted this question purely because there's not enough information out there on how to actually implement this stuff. If there's sufficient interest I'll try to pull together a tutorial/blog to show the steps that I took to get this all up and running.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top