0

I am following the training tutorial on this link: . It gives some exceptions at run time, following is the few initial lines of log trace:

07-07 10:54:51.408: E/AndroidRuntime(31450): FATAL EXCEPTION: main
07-07 10:54:51.408: E/AndroidRuntime(31450): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.location/com.example.android.location.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.location.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.location-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.location-1, /vendor/lib, /system/lib]]
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread.access$600(ActivityThread.java:162)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.os.Handler.dispatchMessage(Handler.java:107)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.os.Looper.loop(Looper.java:194)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread.main(ActivityThread.java:5371)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at java.lang.reflect.Method.invokeNative(Native Method)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at java.lang.reflect.Method.invoke(Method.java:525)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at dalvik.system.NativeStart.main(Native Method)
07-07 10:54:51.408: E/AndroidRuntime(31450): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.location.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.location-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.location-1, /vendor/lib, /system/lib]]
07-07 10:54:51.408: E/AndroidRuntime(31450):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-07 10:54:51.408: E/AndroidRuntime(31450):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
07-07 10:54:51.408: E/AndroidRuntime(31450):    ... 11 more

Below is my manifest file code

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.location"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:description="@string/app_description"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.android.location.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>
    <service
        android:name="com.example.android.location.ReceiveUpdatesIntentService"
        android:label="@string/app_name"
        android:exported="false"></service>
</application>

i also added the internet permission but it is not working

Sam
  • 7,252
  • 16
  • 46
  • 65
  • 1
    check your manifest and add the MainActivity class perfectly..or show your manifest here.. – Ranjit Jul 07 '14 at 06:32
  • Please post your manifest file – busylee Jul 07 '14 at 06:35
  • Check my answer here: http://stackoverflow.com/a/21898031/1785412 – Siddharth_Vyas Jul 07 '14 at 06:42
  • @RanjitPati i posted my manifest file here...please help me... – Nikhil Vashistha Jul 07 '14 at 07:42
  • are you sure..that your MainActivity comes under com.example.android.location package..just check the MainActivity class, the package name and also the spelling..if all things are fine then just change the package name(both in class and in manifest)..and let me know.. – Ranjit Jul 07 '14 at 08:54
  • @RanjitPati still getting the same error...and tried in new project and in that also getting the same error – Nikhil Vashistha Jul 07 '14 at 10:33
  • ok..can you change the MainActivity name to some other name and clean the project..i think it will help you..and also never use `com.example.....` ..always use a valid package name.. – Ranjit Jul 07 '14 at 10:41
  • @RanjitPati there is no effect of that also...i am still getting the same error... – Nikhil Vashistha Jul 07 '14 at 10:49
  • i think you downloaded the zip and import the project..right ? – Ranjit Jul 07 '14 at 10:53
  • @RanjitPati No, i tried that but not able to import that..then i copied the code from that project files and made neccesary changes. Can you please send me the code for updating the location in background at regular intervals. – Nikhil Vashistha Jul 07 '14 at 11:05
  • you just google it..there are many conversations and tutorials you can found..you may check this link.. https://scotthelme.co.uk/android-location-services/ .. – Ranjit Jul 07 '14 at 11:17

1 Answers1

1

I had the same problem starting an Activity which extends MapActivity. It took some time and research to find the answer. Adding uses-library in manifest.xml under application tag fixed the issue:

<uses-library android:name="com.google.android.maps" />
MSquare
  • 6,311
  • 4
  • 31
  • 37