Take the 2-minute tour ×

In my Android project I am using my custom Android library.

In this library I have defined followed Activity (part of the snippet):

public class MyLibAcitivity extends Activity {

    int  counter = 0;
    int[] results = new int[2];

In the main project I would like to extend this Activity:

public class MainActivity extends MyLibAcitivity {

However, I am getting following error:


How I can make it works?

On the other side, maybe I have not correct approach. What I want to achieve, is to have all logic of the application in library and extend few classes (activities) to use different "data source" - my data source is for now another Java class. So basically, in main class I just want to change source to the local one, instead of taking data from library.

Any thoughts?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Must define an explicit constructor

if you're on Eclipse you right click on the class code -> Source -> Generate Constructor from Superclass.

share|improve this answer
add comment

add this to MyLibAcitivity

public MyLibAcitivity() {
        // TODO Auto-generated constructor stub
share|improve this answer
add comment

Your Answer


