Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.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 谷歌地图应用程序在发布时崩溃_Android_Eclipse_Google Maps - Fatal编程技术网

Android 谷歌地图应用程序在发布时崩溃

Android 谷歌地图应用程序在发布时崩溃,android,eclipse,google-maps,Android,Eclipse,Google Maps,我一直在尝试将地图添加到我的应用程序中,我遵循了android开发者HelloLogleMaps教程中的说明,但当我运行“地图”选项时,我的地图只是强制关闭。我已在清单中获得api密钥记录权限 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.MappDemo.mymaps"

我一直在尝试将地图添加到我的应用程序中,我遵循了android开发者HelloLogleMaps教程中的说明,但当我运行“地图”选项时,我的地图只是强制关闭。我已在清单中获得api密钥记录权限

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

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


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" android:debuggable="true" >
        <activity
            android:name=".MappingDemoActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                 <uses-library android:name="com.google.android.maps" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity android:name=".ShowTheMap" android:label="Lat/Long Location"> </activity>
        <activity android:name=".MapMe" android:label="Track Present Location"> </activity>
        <uses-library android:name="com.google.android.maps" />
         <uses-permission android:name="android.permission.INTERNET" />
          <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    </application>

</manifest>
这是我在logcat中看到的。。 这就是我在mappingDemoActivity.java中所拥有的

public class MappingDemoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //add listners for all buttons
        View firstbutton= findViewById(R.id.geocode_button);
        firstbutton.setOnClickListener((OnClickListener) this);
        View secondButton = findViewById(R.id.latlong_button);
        secondButton.setOnClickListener((OnClickListener) this);
        View thirdButton = findViewById(R.id.presentLocation_button);
        thirdButton.setOnClickListener((OnClickListener) this);

    }

    public void onClick(View v)
    {
        switch(v.getId())
        {
        case R.id.geocode_button:
             Log.i("Button","Button 1 pushed");
             Intent j = new Intent(this, ShowTheMap.class);
             startActivity(j);
         break;

         case R.id.latlong_button:
             Log.i("Button","Button 2 pushed");
             Intent k = new Intent(this, ShowTheMap.class);
             startActivity(k);
         break;

         case R.id.presentLocation_button:
             Log.i("Button","Button 3 pushed");
             Intent m = new Intent(this, MapMe.class);
             startActivity(m);
         break; 
        }

    }
标记必须是
的子项,而不是

尝试更改
位置,这会有所帮助。

删除
中的此代码

``

因为它已经在下面的引文中了。

看看SDK中包含的Google MapsDemo,我的路径是:

C:\android sdk\add-ons\addon-google\u API-google\u inc\u10\samples\MapsDemo

我遇到了一个非常令人担忧的问题(),它只出现在某些(!)Android设备上,也没有出现在模拟器中。我所做的是,剥离工作演示,直到它类似于我的基本示例。后来发现,三星手机不接受以com.开头的软件包名称,而其他设备(HTC Flyer)则接受!但这不是您的问题,因为您使用的是com.包名

我可能还会想到一件事。您没有发布main.xml。如果在MapView下方使用嵌套的LinearLayout,也会导致应用程序崩溃。在地图视图的顶部,它可以正常工作。因此,如果您正在使用以下内容:

<LinearLayout ... >

    <com.google.android.maps.MapView ... />

    <LinearLayout ... >
        <Button .../>   
    </LinearLayout>

</LinearLayout>

这可能会导致你的问题。这是可复制的,并抛出完全相同的java.lang.ClassCastException错误

另外,请确保您的语句位于正确的位置,就像前面的家伙所说的那样。第一个必须是节点的直接子节点。第二个必须是节点的直接子节点

我希望这对你有帮助。我被这些东西弄疯了


Bernd

您是否可以添加DDMS中出现的异常。。。这样我们就可以对你的问题有所了解我已经把错误。。请让我知道我到底出了什么问题??你在使用谷歌API模拟器吗?是的,我也在使用同样的模拟器。这是模拟器的问题吗?或者我无法配置的任何东西?似乎这是由于ClassCastException。在MappingDemoActivity.javai中粘贴第19行我甚至做到了。但同样的问题。
`<uses-library android:name="com.google.android.maps" />`
<LinearLayout ... >

    <com.google.android.maps.MapView ... />

    <LinearLayout ... >
        <Button .../>   
    </LinearLayout>

</LinearLayout>