Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 谷歌地图V2异常NoClassDeffFound_Android_Google Maps_Android Activity_Google Maps Android Api 2 - Fatal编程技术网

Android 谷歌地图V2异常NoClassDeffFound

Android 谷歌地图V2异常NoClassDeffFound,android,google-maps,android-activity,google-maps-android-api-2,Android,Google Maps,Android Activity,Google Maps Android Api 2,相信我,在发布之前,我已经看过了至少十几个答案,因为没有一个能帮助我解决我所面临的问题,谷歌的整合真的很糟糕 这里是问题陈述,显示一张地图,就是它 以下是我迄今为止所做的工作 已使用eclipse在工作空间中导入google play services lib项目 已将此项目作为库添加到我的项目中 在manifiest文件中添加了所需的权限和元信息 获得正确的API密钥并添加到manifiest中 Manifiest.XML <?xml version="1.0" encoding="ut

相信我,在发布之前,我已经看过了至少十几个答案,因为没有一个能帮助我解决我所面临的问题,谷歌的整合真的很糟糕

这里是问题陈述,显示一张地图,就是它

以下是我迄今为止所做的工作

已使用eclipse在工作空间中导入google play services lib项目 已将此项目作为库添加到我的项目中 在manifiest文件中添加了所需的权限和元信息 获得正确的API密钥并添加到manifiest中 Manifiest.XML

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

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

    <permission
        android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" >
    </permission>

    <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" >
        <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="AIzaSyCp8z8qSQdO_gFb92iru8Vyr7R7YNQglTo" />

        <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>
    </application>

</manifest>
这是个例外

11-29 19:05:11.868: E/AndroidRuntime(19653): FATAL EXCEPTION: main
11-29 19:05:11.868: E/AndroidRuntime(19653): Process: com.example.mapdemo, PID: 19653
11-29 19:05:11.868: E/AndroidRuntime(19653): java.lang.NoClassDefFoundError: com.google.android.gms.maps.MapFragment
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:19)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.Activity.performCreate(Activity.java:5248)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.os.Handler.dispatchMessage(Handler.java:102)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.os.Looper.loop(Looper.java:136)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.main(ActivityThread.java:5086)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at java.lang.reflect.Method.invokeNative(Native Method)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at java.lang.reflect.Method.invoke(Method.java:515)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at dalvik.system.NativeStart.main(Native Method)
请帮帮我,伙计们,我真的失控了

我的eclipse项目buildpath和android属性的快照

谢谢,
Techfist.

使用xml格式的代码查看地图

<com.google.android.gms.maps.MapView android:id="@+Id/mapView"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />
哈哈哈罗夫

所以最终,我尝试了很多混合和匹配,我甚至安装了android studio并给了该系统一个机会,但在那里浪费了2个小时后,我甚至无法想出如何启动我的应用程序, 最终我回到eclipse,完成了所有的编译、清理、更改编译路径等工作,但都没有成功


解决的办法是更改我的工作区,并使用exactlysame代码重新构建项目。

您是否尝试使用SupportMapFragment而不是MapFragment?@Hareshchelana:因为代码使用的是Activity,而不是FragmentActivity,MapFragment是要使用的合适类。您可能已经手动更改了构建路径或其他内容,以使带有Maps V2的JAR在编译时存在,但没有打包到APK中以供运行时使用。您也尝试过使用support fragment,但它不起作用@Haresh许多人总是在谷歌地图的实现上苦苦挣扎,但没有任何标准或通用的文档或教程。
11-29 19:05:11.868: E/AndroidRuntime(19653): FATAL EXCEPTION: main
11-29 19:05:11.868: E/AndroidRuntime(19653): Process: com.example.mapdemo, PID: 19653
11-29 19:05:11.868: E/AndroidRuntime(19653): java.lang.NoClassDefFoundError: com.google.android.gms.maps.MapFragment
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:19)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.Activity.performCreate(Activity.java:5248)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.os.Handler.dispatchMessage(Handler.java:102)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.os.Looper.loop(Looper.java:136)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at android.app.ActivityThread.main(ActivityThread.java:5086)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at java.lang.reflect.Method.invokeNative(Native Method)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at java.lang.reflect.Method.invoke(Method.java:515)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-29 19:05:11.868: E/AndroidRuntime(19653):    at dalvik.system.NativeStart.main(Native Method)
<com.google.android.gms.maps.MapView android:id="@+Id/mapView"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />
MapView mapView =(MapView) findViewById(R.id.mapView);