0

I am new to app programming, and programming in general. I am still in school for computer science (i'm a sophmore). So please take it easy on me. I hate getting bashed on forums.

My problem is that my app, which will use google maps as the main window crashes immediately. I have posted all my code below, and I am looking for any help to what I might be missing to get this app up and running (or so it does not crash immediately).

A couple things might be wrong:

1) I am now using the SHA1 debug key for this testing stage. Is this right?

2) Do I need to communicate with a type 'GoogleMap' in java to set starting location or anything?

3) I am testing this on my phone (Galaxy SIII) which has worked in the past on simple layouts, but might testing this google maps app need authentication that the phone cannot give?

A couple links I found helpful, up until now: https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api

Google Maps Android API v2 - Sample Code crashes

Notes on setup: I have added android-support-v4.jar and google-play-services.jar to my reference libraries. Properties -> Java Build Path, Libraries

Now, Below, this is all the code I have so far!

Java file (Main.java):

package com.MYDOMAINNAME.www;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
}

xml file (main layout):

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

program manifest:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />
<permission
     android:name="com.MYDOMAINNAME.www.permission.MAPS_RECEIVE"
     android:protectionLevel="signature"/>
<uses-permission  android:name="com.MYDOMAINNAME.www.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-feature android:glEsVersion="0x00020000" android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name= "com.google.android.maps" />
    <activity
        android:name="com.MYDOMAINNAME.www.Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="MY SHA1 DEBUG KEY"/>
</application>
</manifest>

So I would ask, is there anything I need to add or subtract to get this going?

Thanks a bunch!

Log Cat:

12-22 14:45:28.482: E/Trace(10174): error opening trace file: No such file or directory (2)
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapUtilization:0.25
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapIdealFree:8388608
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapConcurrentStart:2097152
12-22 14:45:28.502: D/AndroidRuntime(10174): Shutting down VM
12-22 14:45:28.502: W/dalvikvm(10174): threadid=1: thread exiting with uncaught exception (group=0x4155e438)
12-22 14:45:28.512: E/AndroidRuntime(10174): FATAL EXCEPTION: main
12-22 14:45:28.512: E/AndroidRuntime(10174): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.MYDOMAINAME.www/com.MYDOMAINAME.www.MainActivity}: java.lang.ClassNotFoundException: com.MYDOMAINAME.www.MainActivity
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2012)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread.access$700(ActivityThread.java:139)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.os.Looper.loop(Looper.java:137)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread.main(ActivityThread.java:4918)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at java.lang.reflect.Method.invokeNative(Native Method)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at java.lang.reflect.Method.invoke(Method.java:511)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at dalvik.system.NativeStart.main(Native Method)
12-22 14:45:28.512: E/AndroidRuntime(10174): Caused by: java.lang.ClassNotFoundException: com.MYDOMAINAME.www.MainActivity
12-22 14:45:28.512: E/AndroidRuntime(10174):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
12-22 14:45:28.512: E/AndroidRuntime(10174):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2003)
12-22 14:45:28.512: E/AndroidRuntime(10174):    ... 11 more
Community
  • 1
  • 1
Dustin
  • 1,283
  • 2
  • 9
  • 8

1 Answers1

1

What did you name your java file for Main? It should be Main.java not MainActivity.java.
If you look at the log , this line 12-22 14:04:16.043: E/AndroidRuntime(9154): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gotonight.www/com.gotonight.www.MainActivity}: java.lang.ClassNotFoundException: com.gotonight.www.MainActivity
its trying to find
com.gotonight.www.MainActivity but your Main class is com.gotonight.www.Main

wtsang02
  • 18,603
  • 10
  • 49
  • 67
  • I will change that now, and see if that fixes anything – Dustin Dec 22 '12 at 19:22
  • OK! NO CRASHING! I have literally built this project from scratch in many scenarios trying to find the issue. But this is just odd that this was an issue today. -Thanks! I will keep testing to see... but I think there might be another error around the corner. – Dustin Dec 22 '12 at 19:26
  • If you find this answer helpful. You can choose this as correct answer by checking the check on the left of this for others reference. If you have any other questions on another topic, you have to post in another post. – wtsang02 Dec 22 '12 at 19:28
  • Well my issue remains, google maps will not load. You correctly found that I forgot to change my manifest file – Dustin Dec 22 '12 at 19:35
  • A tip is, questions being answered here is not just for you. If you simply change your logs and code to ask another question. Other people viewing this later on will not know what is going on and will have 0 benifiet for them. – wtsang02 Dec 22 '12 at 19:37