0

我正在尝试使 Android 'Google Maps Android API v2' 的示例代码正常工作。我得到的项目没有错误。但是,当我尝试在 Everpad 上运行该应用程序时,该应用程序立即崩溃。

日志输出:

08-30 17:12:42.620: E/dalvikvm(4352): Could not find class 'com.dvp.android.gallery.GPS', referenced from method com.dvp.android.gallery.Acceuil$5.onClick
08-30 17:12:47.670: E/InputDispatcher(3263): Motion event has invalid action code 0xa
08-30 17:12:47.760: E/InputDispatcher(3263): Motion event has invalid action code 0x9
08-30 17:12:47.760: E/InputDispatcher(3263): Motion event has invalid action code 0x7
08-30 17:12:47.850: E/AndroidRuntime(4352): FATAL EXCEPTION: main
08-30 17:12:47.850: E/AndroidRuntime(4352): java.lang.NoClassDefFoundError: com.dvp.android.gallery.GPS
08-30 17:12:47.850: E/AndroidRuntime(4352):     at com.dvp.android.gallery.Acceuil$5.onClick(Acceuil.java:57)

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.dvp.android.gallery"
      android:versionCode="1"
      android:versionName="1.0">
    <permission
            android:name="com.dvp.android.gallery.maps.permission.MAPS_RECEIVE"
            android:protectionLevel="signature" />
    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true"/>

    <application android:icon="@drawable/ic_bardo" android:label="@string/app_name">
        <activity android:name=".Acceuil"
                  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=".Objets" android:label="Objets">  </activity>
        <activity android:name=".GPS"
                  android:label="GPS">
        </activity>
        <activity android:name=".Detail" android:label="Detail"></activity>
        <activity
                android:name=".Galeries"
                android:label="Galeries"
                />
        <activity
                android:name=".Evennements"
                android:label="Evennements"/>
        <activity
                android:name=".Infos"
                android:label="Infos"/>
    </application>
    <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyA0HMTTGLqlYaq6jOuS0imbjt7GmUHyK0c"/>

    <uses-sdk android:minSdkVersion="4" />


    <uses-permission android:name="com.dvp.android.gallery.maps.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    <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" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

</manifest> 

Java 代码

package com.dvp.android.gallery;

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

import com.google.android.gms.maps.SupportMapFragment;


public class GPS extends FragmentActivity{

   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gps);
       SupportMapFragment fragment = new SupportMapFragment();
       fragment.getFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();

    }


}

最后是 XML:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          class="com.google.android.gms.maps.SupportMapFragment"
/>

我用谷歌搜索并没有发现有关此异常的信息。我真的很困惑这个问题,不知道如何解决它。有谁知道如何解决它?谢谢。

4

2 回答 2

0

尝试这个:

<uses-library android:name="com.google.android.maps" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

您可以实现以下内容:

<application
        android:allowBackup="true"
        android:icon="@drawable/icn_button2"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.gc.materialdesigndemo.ui.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="br.com.informapa.MESSAGE" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
于 2015-04-22T01:12:37.463 回答
0

您在清单文件中指定的包与您为其中的活动提供的包之间存在某种不匹配。

尝试改变:

 <activity
        android:name="in.wptrafficanalyzer.locationgooglemapv2demo.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: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>

并且不要用带壳的后者编写一些包,而有些则不是,将您的权限包更改为在包部分中所写的那样:

 <permission
      android:name="in.wptrafficanalyzer.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>

<uses-permission android:name="in.wptrafficanalyzer.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"/>
于 2013-08-29T00:01:35.010 回答