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 trial

Android Android Lists and Adapters (2015) Updating the Data Model Finishing the Data Model

Hendy Budhigraha
Hendy Budhigraha
17,328 Points

My app crashes after I moved MainActivity class to ui package. anyone can help?

Using the default settings in the app configuration, it says "Default Activity not found"

After choosing 'Launch' and directing it to MainActivity, it says "the activity 'MainActivity' is not declared in AndroidManifest.xml"

Hendy Budhigraha
Hendy Budhigraha
17,328 Points

The following is the AndroidManifest.xml file

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.hendy.stormy" >

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".ui.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

2 Answers

Try something like com.example.hendy.stormy.MainActivity. The first bit should be whatever your main package is named.

Hendy Budhigraha
Hendy Budhigraha
17,328 Points

Hi, thank you for your response.

I tried the code, but it is not working as well. Is the version of android studio affecting this error? because I am using the old version that Ben provided in his first video

Hi Mandy,

The code works fine for me. Check the name of your MainActivity and your package name, and if you named your ui package lower or upper case. If it's not working, please provide us with a screenshot of your file structure.

Best Regards, Philip