0

I'm getting the following error when I try to run my application in Android Studio emulator "Unfortunately, App has stopped working". Initially, I had some problems with my Manifest file where the android:theme was not set to AppCompat and my activities path was incorrect. However, after fixing those problems I'm getting the following exception in my logcat:

     --------- beginning of crash
FATAL EXCEPTION: main
                                                                             Process: PID: 2437
                                                                             java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.MyApp/main.AuthenticationActivity}: java.lang.ClassNotFoundException: Didn't find class "main.AuthenticationActivity" on path: DexPathList[[zip file "/data/app/com.android.MyApp-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:135)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                 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:903)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                                              Caused by: java.lang.ClassNotFoundException: Didn't find class "main.AuthenticationActivity" on path: DexPathList[[zip file "/data/app/com.android.MyApp-1/base.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:1066)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:135) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                                 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:903) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

And this is my AndroidManifest file:

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


    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission android:name="android.permission.READ_PROFILE"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat">
        <activity android:name="main.AuthenticationActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name="main.HomeActivity"
                  android:label="@string/app_name">
        </activity>
    </application>

</manifest>

I went through all the posts relevant to this website and tried my best to form my question clearly. I'm still new to this so I'm open to all constructive criticism.

From what I understand it's saying that it couldn't find the file path for the main activity, and I double checked that I had the correct file path entered on all of my files. Any help would be really appreciated.

  • Can you disable instant run: http://stackoverflow.com/questions/35168753/instant-run-in-android-studio-2-0-how-to-turn-off and do a full clean and rebuild to see if you get the error again. – Morrison Chang Nov 28 '16 at 07:09
  • Can u remove compile 'com.android.support:support-v4:25.0.1' line and try once? Anyway u have v7 support library dependency so – Raghavendra Nov 28 '16 at 07:09
  • @Raghavendra It still gave me the same error. –  Nov 28 '16 at 07:13
  • @MorrisonChang Did exactly what you said and it still gave me the same error. –  Nov 28 '16 at 07:17

1 Answers1

0

change your code in manifest :"main.AuthenticationActivity" to ".main.AuthenticationActivity".

machinezhou
  • 679
  • 2
  • 6
  • 16