Error when using activities in a child package

0

I have a problem with my Android project in Eclipse. After implementing the functionalities, I came to a total of 10 activities and 8 other classes. From there I realized the need to structure the code and created child packages within the project package, as follows:

RememberingthatforEclipsetodisplaythepackagesinthiswayI'vechangedthewaypackagesareviewedtodisplaybyhierarchy.

WithintheactivitiespackageIputalltheactivitiesoftheproject.WhensavingeverythingandrunningIgetthefollowingerror:

01-0319:59:59.630:E/AndroidRuntime(361):FATALEXCEPTION:main01-0319:59:59.630:E/AndroidRuntime(361):java.lang.RuntimeException:UnabletoinstantiateactivityComponentInfo{com.example.meu_projeto/com.example.meu_projeto.MainActivity}:java.lang.ClassNotFoundException:com.example.meu_projeto.MainActivityinloaderdalvik.system.PathClassLoader[/data/app/com.example.meu_projeto-1.apk]01-0319:59:59.630:E/AndroidRuntime(361):atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)

I'vetriedtomakethischangeinAndroidManifest.xml:

Before:

<activityandroid:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Then I changed this line:

android:name=".activities.MainActivity"

But it did not help, can anyone help?

    
asked by anonymous 03.01.2016 / 21:19

1 answer

1

The package in your MainActivity class is wrong. Change the "name" attribute of your MainActivity class to your AndroidManifest.xml by doing the following:

Before:

<activity
    android:name=".MainActivity"
    android:label="@string/title_activity_main" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

Then just change this line:

android:name="com.example.meu_projeto.activities.MainActivity"

You should apply this change in AndroidManifest.xml to all activities that are in the child package.

    
04.01.2016 / 00:16