Q:

Android model view controller implementation giving error

I have a project that I am working on and everything was correct from the time I created the project in android studio with one Activity (Login activity)
Later as I wanted to implement MVC on the project, I created three more packages (app, activity and helper) inside the original package com.otemainc.smartmenu I then moved the LoginActivity.java file to the activity package.
then imported the R class into it, changed the packed declaration line to the correct one but when I run in on my phone, it gives me the following error
    12-16 13:07:27.352 4608-4608/com.otemainc.smartmenu E/AndroidRuntime: FATAL EXCEPTION: main                                                                      Process: com.otemainc.smartmenu, PID: 4608
   java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.otemainc.smartmenu/com.otemainc.smartmenu.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "com.otemainc.smartmenu.LoginActivity" on path: DexPathList[[zip file "/data/app/com.otemainc.smartmenu-1/base.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
    at android.app.ActivityThread.access$800(ActivityThread.java:178)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
   at android.os.Handler.dispatchMessage(Handler.java:111)
   at android.os.Looper.loop(Looper.java:194)
   at android.app.ActivityThread.main(ActivityThread.java:5631)
   at java.lang.reflect.Method.invoke(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.otemainc.smartmenu.LoginActivity" on path: DexPathList[[zip file "/data/app/com.otemainc.smartmenu-1/base.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.otemainc.smartmenu-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5631) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
Suppressed: java.lang.ClassNotFoundException: com.otemainc.smartmenu.LoginActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                            ... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

A:

This error is because your activity class is not being found, since you moved it to another folder, you need to change the activity name in the manifest file. you will fing it looking like this
       <activity
        android:name=".LoginActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

This means that the activity file is being looked for in the original root package. You need to chage the name to activity.LoginActivity.
The code will look something like this
       <activity
        android:name=".activity.LoginActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

