0

我正在使用 Xamarin,在尝试加载Activity.

这是错误:

Android.Content.ActivityNotFoundException: Unable to find explicit activity class {com.xamarin.docs.android.mapsandlocationdemo2/simplemapdemo.MapWithMarkersActivity}; have you declared this activity in your AndroidManifest.xml?

这是我的 AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="4.0" package="com.xamarin.docs.android.mapsandlocationdemo2">
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="18" />
    <!-- Google Maps for Android v2 requires OpenGL ES v2 -->
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <!-- We need to be able to download map tiles and access Google Play Services-->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Allow the application to access Google web-based services. -->
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!-- Google Maps for Android v2 will cache map tiles on external storage -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- These are optional, but recommended. They will allow Maps to use the My Location provider. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- Notice here that we have the package name of our application as a prefix on the permissions. -->
    <uses-permission android:name="com.xamarin.docs.android.mapsandlocationdemo2.permission.MAPS_RECEIVE" />
    <permission android:name="com.xamarin.docs.android.mapsandlocationdemo2.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <application android:label="@string/app_name">
        <!-- Put your Google Maps V2 API Key here. This key will not work for you.-->
        <!-- See https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key -->
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="key_goes_here" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    </application>
</manifest>

Activity我正在加载,namespace SimpleMapDemo这是类声明:

public class MapWithMarkersActivity : Android.Support.V4.App.FragmentActivity

这是我的活动布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true"
    android:padding="5dip">
    <FrameLayout
        android:id="@+id/mapWithOverlay"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:layout_below="@+id/thumbnail" />
    <ListView
        android:id="@+id/List"
        android:visibility="gone"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="50dp"
        android:layout_marginBottom="50dp" />
    <EditText
        android:id="@+id/inputSearch"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:hint="Find..."
        android:layout_alignParentTop="true" />
</RelativeLayout>

我可以请一些帮助以使此代码正常工作吗?

提前致谢

编辑

这现在在 AndroidManifest.xml 中

<application android:label="@string/app_name">
    <activity android:name="com.xamarin.docs.android.mapsandlocationdemo2/simplemapdemo.MapWithMarkersActivity" android:label="@string/app_name" ></activity>
    <!-- Put your Google Maps V2 API Key here. This key will not work for you.-->
    <!-- See https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key -->
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="key_goes_here" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>

这仍然是错误:

Unable to find explicit activity class {com.xamarin.docs.android.mapsandlocationdemo2/simplemapdemo.MapWithMarkersActivity}; have you declared this activity in your AndroidManifest.xml?
4

2 回答 2

1

在清单中声明你Activity,里面<application>是这样的:

<activity android:name="com.example.pacakge.MainActivity" android:label="@string/app_name" ></activity>
于 2014-05-17T12:10:31.400 回答
0

您必须在清单中注册您的活动

于 2014-05-17T12:09:26.253 回答