java.lang.ClassNotFoundException:没找到类" com.google.android.gms.maps.SupportMapFragment"在路上

时间:2014-11-03 08:24:15

标签: android google-cloud-messaging

请帮我解决

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="100" >

    <include
        android:id="@+id/headerLayout"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="10"
        layout="@layout/header" />

    <LinearLayout
        android:id="@+id/contentLayout"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="90"
        android:background="@drawable/background_login"
        android:gravity="center"
        android:orientation="vertical" >

     <!--    <Button
             android:id="@+id/btn_phone_code"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="@dimen/five_dp"
            android:layout_marginLeft="@dimen/twenty_dp"
            android:layout_marginRight="@dimen/twenty_dp"
            android:background="@drawable/rounded_edittext"
            android:focusable="false"
            android:hint=""
            android:padding="@dimen/seven_dp" />
 -->
        <LinearLayout
            android:id="@+id/content1Layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/twenty_dp"
            android:layout_marginRight="@dimen/twenty_dp"
            android:gravity="center" >

          <!--   <EditText
                android:id="@+id/edtCountryCode"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="@dimen/five_dp"
                android:background="@drawable/rounded_edittext"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:inputType="number"
                android:padding="@dimen/seven_dp" />
 -->
   <Button
                android:id="@+id/btn_phone_code"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="@dimen/five_dp"
                android:background="@drawable/rounded_edittext"
                android:focusable="false"
                  android:hint="Code"
                android:focusableInTouchMode="false"
                android:inputType="number"
                android:padding="@dimen/seven_dp" />

            <EditText
                android:id="@+id/et_no_register"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/rounded_edittext"
                android:hint="@string/mobile_no"
                android:inputType="phone"
                android:maxLength="10"
                android:padding="@dimen/seven_dp" />
        </LinearLayout>

        <EditText
            android:id="@+id/et_email_register"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/twenty_dp"
            android:layout_marginRight="@dimen/twenty_dp"
            android:layout_marginTop="@dimen/five_dp"
            android:background="@drawable/rounded_edittext"
            android:hint="Email Address"
            android:padding="@dimen/seven_dp" >
        </EditText> 

        <Button
            android:id="@+id/btn_register"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/twenty_dp"
            android:layout_marginRight="@dimen/twenty_dp"
            android:layout_marginTop="@dimen/ten_dp"
            android:background="@drawable/continue_icon"
            android:text="@string/btncontinue"
            android:textColor="@color/white" />
    </LinearLayout>

    <fragment
        android:id="@+id/map"
     android:name="com.google.android.gms.maps.MapFragment"

        android:layout_width="1dp"
        android:layout_height="1dp" />

</LinearLayout>
中的

<uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="18" />

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!--
     The following two permissions are not required to use
     Google Maps Android API v2, but are recommended.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <permission
        android:name="com.addon.zutkut.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="VALUE" />

但是在运行时

11-03 08:18:54.792: E/Trace(1313): error opening trace file: No such file or directory (2)
11-03 08:18:57.442: E/AndroidRuntime(1313): FATAL EXCEPTION: AsyncTask #1
11-03 08:18:57.442: E/AndroidRuntime(1313): java.lang.RuntimeException: An error occured while executing doInBackground()
11-03 08:18:57.442: E/AndroidRuntime(1313):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.lang.Thread.run(Thread.java:856)
11-03 08:18:57.442: E/AndroidRuntime(1313): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging
11-03 08:18:57.442: E/AndroidRuntime(1313):     at com.addonwebsolution.App.activity.RegisterActivity$RegisteGCMId.doInBackground(RegisterActivity.java:116)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at com.addonwebsolution.App.activity.RegisterActivity$RegisteGCMId.doInBackground(RegisterActivity.java:1)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-03 08:18:57.442: E/AndroidRuntime(1313):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-03 08:18:57.442: E/AndroidRuntime(1313):     ... 4 more

错误已开启:

class RegisteGCMId extends AsyncTask<Void, Void, Void> {

        @Override
        protected Void doInBackground(Void... params) {
            try {
                GoogleCloudMessaging gcm = GoogleCloudMessaging
                        .getInstance(RegisterActivity.this);
                regid = gcm.register(Constant.SENDER_ID);
                final SharedPreferences prefs = PreferenceManager
                        .getDefaultSharedPreferences(RegisterActivity.this);
                Editor editor = prefs.edit();
                editor.putString(Pref.GCM_ID, regid);
                editor.commit();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return null;
        }

1 个答案:

答案 0 :(得分:0)

当你正在编译API 9时,你必须使用支持地图片段而不是Map片段。用这个片段放置地图片段

<fragment
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />