I have a library project which has all functionality and some activities, and I also have a wrapper activity which only has a JSON configuration string and some styling. I imported the library to the wrapper project, and in the wrapper project I'm setting one of the library's activities as the launch activity, but then get an error that the selected activity from the library is not an activity subclass or alias.
What does that mean and can I correct this?
The Activity that is supposed to be launched:
package dk.borgertip.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import dk.borgertip.R;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread startTimer = new Thread() {
@Override
public void run() {
try {
sleep(3000);
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
startTimer.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_splash, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
The project structure: (The Borgertip module is the library that contains the activity to launch which extends Activity)
The 'Edit Configuration' dialog with the error:
What do I do wrong?
I had the same problem, in this particular case it was caused after refactoring some code and delete the activity that was set as the application main activity.
I made sure the <activity></activity>
declaration was also removed from the manifest.xml
file but it was still set as the main activity whitin the Run/Debug configurations
section in Android Studio.
Just go to run/Edit configurations.../Android App/app
Select the "General"
tab and look at the "Launch Options"
section. There you can choose the activity you want to set as the main one.
Hope this will be useful for someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With