Android.Content.ActivityNotFoundException when loading a fra



我正在使用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>

我正在加载的Activitynamespace SimpleMapDemo中,这是类声明:

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

下面是Activity的布局:

<?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>

我能有一些帮助让这个代码工作吗?

Thanks in advance

编辑

现在在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?

在清单中声明您的Activity,在<application>中像这样:

<activity android:name="com.example.pacakge.MainActivity" android:label="@string/app_name" ></activity>

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

相关内容

  • 没有找到相关文章

最新更新