Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBenjamin Young
5,881 PointsI need help clarifying an issue I am having with Android Studio.
Whenever I run the Fun Facts program and then launch the emulator I get the error
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.teamtreehouse.funfacts/.MainActivity } Error type 3 Error: Activity class {com.teamtreehouse.funfacts/com.teamtreehouse.funfacts.MainActivity} does not exist.
However I am not sure why this would happen. I did everything else correctly. Or so I thought.
5 Answers
Jon Kussmann
Courses Plus Student 7,254 PointsCan you post your AndroidManifest file as well as the package name of your MainActivity?
Benjamin Young
5,881 PointsThe Android Manifest is: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.teamtreehouse.funfacts" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Package name: com.teamtreehouse.funfacts
Jon Kussmann
Courses Plus Student 7,254 PointsNothing is jumping out to me yet, could you also post your MainActivity code?
Benjamin Young
5,881 PointsAbsolutely, and thank you for your time as well! One moment.
Benjamin Young
5,881 Pointsackage com.teamtreehouse.funfacts;
import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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_main, 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);
}
}
I feel as though the answer is extremely obvious but I just cannot figure it out.
Jon Kussmann
Courses Plus Student 7,254 PointsYour code looks fine to me.
In Android Studio:
Build -> Clean Project
Build -> Rebuild Project
Try running again. If that doesn't work, close and reopen Android Studio.
Jon Kussmann
Courses Plus Student 7,254 PointsAlso, do you have a physical device you can try running the app from?
Benjamin Young
5,881 PointsI do not, I need to download Genymotion and try that but so far everything is running smoothly! I am going to follow along with the lessons and see if I run into any more trouble with the program.