Created
January 13, 2016 13:51
-
-
Save hanspeide/75f7f16551f5e273ff89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
if (requestInjection()){ | |
inject(); | |
} | |
} | |
private void inject() { | |
ObjectGraph appGraph = Injector.obtain(getApplication()); | |
appGraph.inject(this); | |
} | |
abstract boolean requestInjection(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeActivity extends BaseActivity { | |
@Inject ApiService apiService; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.some_layout); | |
} | |
@Override | |
boolean requestInjection() { | |
return true; | |
} | |
} |
Solution: Add SomeActivity.class to the module
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile error:
Caused by: java.lang.IllegalArgumentException: No inject registered for members/com.example.SomeActivity. You must explicitly add it to the 'injects' option in one of your modules.