Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

TypeNotPresentException when Android component enable set to false #129

Closed
niqo01 opened this issue Dec 22, 2012 · 2 comments
Closed

TypeNotPresentException when Android component enable set to false #129

niqo01 opened this issue Dec 22, 2012 · 2 comments

Comments

@niqo01
Copy link
Contributor

niqo01 commented Dec 22, 2012

I am using Dagger on Anrdoid and I am having a TypeNotPresentException when one of my Android component is set to false.
Please find below the detailed of what I am doing:
I have two declared components in my AnrdoidManifest:

  • One which is only enable prior to Honeycomb,
  • One enable only on Honeycomb and after.

below an extract of my AndroidManifest.xml

<activity
 android:name=".ui.search.SearchHoneycombActivity"
 android:enabled="@bool/hasHoneycomb">
 <intent-filter>
  <action android:name="android.intent.action.SEARCH" />
 </intent-filter>

 <meta-data
   android:name="android.app.searchable"
   android:resource="@xml/searchable" />
 </activity>
 <activity
  android:name=".ui.search.SearchEclairActivity"
  android:enabled="@bool/priorHoneycomb">
  <intent-filter>
    <action android:name="android.intent.action.SEARCH" />
  </intent-filter>

 <meta-data
   android:name="android.app.searchable"
   android:resource="@xml/searchable" />
</activity>

Here the extract of my only module

@Module(
 entryPoints = {
    SearchHoneycombActivity.class,
    SearchEclairActivity.class,
    ...}})
  public class ProdModule {
 ...

Apparently declaring the entryPoints are mandatory. I was wondering how to deal with this tricky use case?

@JakeWharton
Copy link
Collaborator

You might want to create HoneycombModule and EclairModule and then conditionally add each module to the object graph when you create it.

final Object searchModule;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  searchModule = new HoneycombModule();
} else {
  searchModule = new EclairModule();
}

...

og = ObjectGraph.create(
  new ThisModule(),
  new ThatModule(),
  searchModule
);

@niqo01
Copy link
Contributor Author

niqo01 commented Dec 22, 2012

Very straight forward. That's perfect, thanks a lot.

@niqo01 niqo01 closed this as completed Dec 22, 2012
cgruber added a commit to cgruber/dagger that referenced this issue Mar 28, 2015
…32292dab18eafe393676bf6d3a32725219078

Merge from google's internal repository from writing branch 02a3229
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants