Java 我无法让谷歌地图API在我的android应用程序(V2)上运行

Java 我无法让谷歌地图API在我的android应用程序(V2)上运行,java,android,xml,eclipse,google-maps,Java,Android,Xml,Eclipse,Google Maps,在main2.xml中,显然没有错误。main.xml也是如此,但我认为问题就在这里。 快速总结一下这个应用程序是什么:点击一个按钮就可以使用谷歌地图,但是我会出错,所以我可以在测试时加载主菜单。 XML 我没有足够的代表发布图片,所以可以找到错误图片 main2.xml <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk

main2.xml中,显然没有错误。main.xml也是如此,但我认为问题就在这里。
快速总结一下这个应用程序是什么:点击一个按钮就可以使用谷歌地图,但是我会出错,所以我可以在测试时加载主菜单。 XML
我没有足够的代表发布图片,所以可以找到错误图片

main2.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="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment"/> 
App2Activity中,我收到错误“无法解析导入com.example.clubnightsdels.R”

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Club Deals"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="GPS locations" />
    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Closest Deals"
        android:onClick="open_close_deals" />

    <Button
        android:id="@+id/button6"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Cheapest Deals"
        android:onClick="open_cheap_deals" />


    <Button
        android:id="@+id/button7"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Best Value Deals"
        android:onClick="best_value" />

    <Button
        android:id="@+id/button8"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Best Events"
        android:onClick="best_events" />

    <Button
        android:id="@+id/button9"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="News" 
        android:onClick="news"/>
</LinearLayout>
App2Activity.java

package com.example.clubnightsdeals;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import com.example.clubnightsdeals.R;

public class App2Activity extends Activity {

    Button button;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);
    }
 }  
舱单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.clubnightsdeals"
    android:versionCode="1"
    android:versionName="1.0" >
  <permission
        android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="18" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

     <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/clubnightsdeals"
            android:name=".AppActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <uses-library
        android:name="com.google.android.maps" />
        <activity
            android:label="@string/clubnightsdeals"
            android:name=".App2Activity" >
        </activity>

        <meta-data
     android:name="com.google.android.maps.v2.API_KEY"
     android:value="AIzaSyDetfYqNFORnvtR245fht3RIK25T6DRY" />
          <activity
            android:name="info.androidhive.googlemapsv2.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppBaseTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>



</manifest>

  
            
                
 
                
            
        

您指向了错误的R.java文件。替换以下导入行

import android.R;


在AppActivity.java文件中

您的错误表明您尚未关闭清单文件中的
标记。
确保您已关闭活动标签,如

首先删除

<intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

在清单中(应用程序中不能有2个启动活动),然后尝试导入R库。

如果仍然存在此错误,请检查您的xml文件-确保检查所有xml文件。

您必须
导入com.example.clubnightsdels.R
在活动中尝试在
main2.xml
中将
fragment
放入
FrameLayout
或将fragment的类设置为
SupportMapFragment
。您的最低api级别是什么?嘿,我将其放入了,但现在我得到了导入com.example.clubNightsDels.R在替换该行后无法解析,你需要清理你的项目一次。嘿,这样做之后,错误似乎仍然存在。我添加了这张图片,它显示了console@user2849976,由于代理问题,我无法看到该链接,请将您的图像发布到其他地方好吗?@user2849976,这表明在您的清单文件中,您尚未关闭标记。关闭您的活动,谢谢您的帮助。我把它贴在描述里了。就我所知,我确实关闭了它(显然我错了)。@user2849976那么我想你的问题现在已经解决了。不,我的意思是它似乎已经关闭了。它仍然给我同样的错误,但是/尝试清理您的项目@user2849976不幸的是,这也不起作用。我正在考虑重新开始。
import com.example.clubnightsdeals.R; 
<intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>