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 Implementing Designs for Android Customizing a ListView for the Inbox Fun with Refactoring

Not so fun with refactoring...please help I knew I was going to mess this up...

I messed up the manafest after refactoring it...please take a look.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Jellybean.jellybean" android:versionCode="1" android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="21" />

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

<uses-feature
    android:name="android.hardware.camera"
    android:required="true" />

<application
    android:name=".JellybeanApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".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>
    <activity
        android:name="com.Jellybean.jellybean.ui.LoginActivity"
        android:label="@string/title_activity_login"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="com.Jellybean.jellybean.ui.SignupActivity"
        android:label="@string/title_activity_signup"
        android:parentActivityName="com.Jellybean.jellybean.ui.LoginActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="com.Jellybean.jellybean.ui.ForgotPasswordActivity"
        android:label="@string/title_activity_forgot_password"
        android:parentActivityName="com.Jellybean.jellybean.ui.LoginActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name=".EditFriendsActivity"
        android:label="@string/title_activity_edit_friends"
        android:parentActivityName="com.Jellybean.jellybean.ui.MainActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name=".RecipientsActivity"
        android:label="@string/title_activity_recipients"
        android:parentActivityName="com.Jellybean.jellybean.ui.MainActivity"
        android:screenOrientation="portrait" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.Jellybean.jellybean.MainActivity" />
    </activity>
    <activity
        android:name=".ViewImageActivity"
        android:label="@string/title_activity_view_image"
        android:parentActivityName="com.Jellybean.jellybean.ui.MainActivity" 
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.Jellybean.jellybean.MainActivity" />
    </activity>
</application>

</manifest>

Yeah I did this step in Android Studio and mine did something similar where it made nested folders all called "com.example.ribbit" and refactored all the classes and the manifest to reflect this. I had to look at a past project's manifest file to fix it.

Android Studio automatically assumes the "com.example.ribbit" part so you don't have to type that in when naming a new package. I would advise people to take this step cautiously but they probably won't see this until it's too late :p

2 Answers

Ben Holland
PLUS
Ben Holland
Courses Plus Student 4,062 Points

Hi Jake

In Android auto-generated files should not be refactored because they referenced in other places so just refactor it too AndroidManifest.xml ? Also the top part is not needed.

For Android Studio, after creating the packages, I simply cut and paste the files into the new packages and it updated the manifest appropriately. Now for some reason (not sure if it's something I did) somehow I wound up with 2 com.teamtreehouse.ribbit packages. It made a 2nd com.teamtreehouse.ribbit package within the 1st, and then the UI, adapter, and utils packages were placed in this 2nd package. To resolve this, I cut these 3 packages and pasted then into the 1st top level com.teamtreehouse.ribbit package. Then I deleted the extra com.teamtreehouse.ribbit package which at this point was empty. Android Studio refactored everything appropriately and I had no errors.