0

I am developing an android application and after moving around some libraries and adjusting my workspace so that it can sync with github I am now encountering a new error that I have not had in the past. Here is the print out in LogCat.

FATAL EXCEPTION: main
Process: com.exmple.loop, PID:1000
java.lang.RuntimeException: Unable to instantiate activity 
ComponentInfo{com.example.loop/com.example.loop.MainActivity}: 
java.lang.ClassNotFoundException: Didn't find class "com.example.loop.MainActivity" on 
path: DexpathList[[zip file "/data/app/com.example.loop-2.apk"]...

I can supply more if needed. I have checked stackoverflow for solutions and came across some that proved to be unhelpful. Here is the first question I found and here is the second. I tried the helpful solutions for both and nothing seems to work. Similar to the user in the first question, the exception is thrown before any line I write because it is failing to recognize my main activity as a class.

Here is my android manifest.

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

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

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

<application
    android:allowBackup="true"
    android:name="com.example.loop.LoopApplication"
    android:icon="@drawable/loop_icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.Loop" >
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <activity
        android:name="com.example.loop.MainActivity"
        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:theme="@style/AppTheme" android:logo="@drawable/loop_icon" android:name="LoginActivity">

    </activity>

</application>

</manifest>
Community
  • 1
  • 1
user3591522
  • 133
  • 1
  • 8

4 Answers4

1

If you look in your logcat it writes:

ComponentInfo{com.exmple.loop/com.example.loop.MainActivity}: 

com.exmple.loop 

I think it should be com.example.loop

Try remove this line and see if it works:

android:name="com.example.loop.LoopApplication"
Ultimo_m
  • 4,724
  • 4
  • 38
  • 60
  • My apologies. I had to copy and type the logcat response by hand and probably missed a key. It was indeed com.example.loop. – user3591522 Jun 08 '14 at 17:24
  • I removed the application line like you said and I am still getting the same error, and even if that would fix it I am using a custom class that extends application for Google Analytics. It's really weird, working one day and then I move some referenced libraries to a new folder and then it no longer can find a file i never touched. – user3591522 Jun 13 '14 at 15:02
  • Ok, try creating a `new project` with the same `package name` but not the same `project name` because its not allowed in the same workspace, then copy and paste that project `manifest.xml` to this porject that you want to fix – Ultimo_m Jun 13 '14 at 15:47
0

Change your activity tag to this and it will run:

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

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
CodeWarrior
  • 5,026
  • 6
  • 30
  • 46
  • I have tried renaming the activity to just about anything to make it run and no luck. It ran before I moved the libraries to a different folder, would it really make my project no longer recognize the file at the current path? – user3591522 Jun 15 '14 at 16:33
0

There are many causes to this. I'll try to name as much as I can.

1.You tryed to add the library in your Java Build Path and not in the Android libraries. rigt-click on your project> properties > Android. At the bottom there is a place for Android libraries.

2.Right-click your src folder>Build Path > Use as Source Folder

3.Right-click you src folder> Build Path> Configure output folder > set projects default output folder

4.Right-clikc project > Java Build Path > Order and Export > check Android Private Libraries (You CAN'T have any library in Android Private Libraries and in the outside at the same time)

5.If you have set the project to use Maven and removed it after. Delete the bin folder and the pom.xml

6.Check if you R file is being generated. Delete it and see if it rebuild. If not look in your manifest or xml files for any error.

7.Check that Build Atomatically is checked.

Hope this help, I have had this that problem many times, and each time it was something else.

Good luck!

Edit: there is a 8 cause but this is not your case. Its if you forget to add the class to the manifest.

  • Thank you for the help. While at first I thought this would be the solution, unfortunately I have tried all of these and have had no luck. Could you elaborate on #4? In my projects build path I already had Android Private Libraries checked, but I am not sure what you mean by "in the outside." Could the be something about that causing this error? – user3591522 Jun 15 '14 at 16:29
  • Yes sorry. What I mean is that in my case I had doble imported the libreries. I had them referenced in my Java Build Path and copied them into my libs folder manualy. It was the first time so I tried bouth at the same time, and had a lot of problem because of that. So if you have done something similar, just remove any reference to the library en Java Build Path and only check private librery.This error is horrible, its really hard to know from where it comes :( –  Jun 15 '14 at 18:04
0

So after trying every bit of advice given to me I decided to create a new Android Project and copy all the files from the old project the appropriate folder in the new project. While this took a little bit of time that could have probably been shorter if I had messed with the original project some more, ultimately it did fix the error I was encountering and the project now runs.

user3591522
  • 133
  • 1
  • 8