1

我目前正在使用 android studio,我已将我的活动放入清单文件中,我相信我调用它是正确的。我不断收到此错误:

造成的:android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.ca.android.easycall.customers1}; have you declared this activity in your AndroidManifest.xml?

这是我的电话:

Intent actCustomers1 = new Intent(this, customers1.class);
startActivity(actCustomers1);

这是我的清单:

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

    <permission android:name="android.permission.CALL_PHONE" />

    <uses-permission android:name="android.permission.CALL_PHONE" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.ca.android.easycall.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>
        <activity
            android:name=".customers1"
            android:label="@string/title_activity_customers1" >
        </activity>
        <activity
            android:name=".customers2"
            android:label="@string/title_activity_customers2" >
        </activity>
    </application>

</manifest>
4

4 回答 4

3

From what you posted, it looks like your class customers1 is not declared in package com.ca.android.easycall

When you have something like android:name=".customers1", Android compiler will try to prepend it with package name package="com.ca.android.easycall", so it becomes com.ca.android.easycall.customers1

Quoted from Android official documentation:

android:name

The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element.

However because you got the error log:

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.ca.android.easycall.customers1}; have you declared this activity in your AndroidManifest.xml?

So it must be either customers1 is not declared or customers1 is not in com.ca.android.easycall package

于 2013-10-11T05:26:27.570 回答
1

试试这个,

<activity
        android:name="com.ca.android.easycall.customers1"
        android:label="@string/title_activity_customers1" >
    </activity>
    <activity
        android:name="com.ca.android.easycall.customers2"
        android:label="@string/title_activity_customers2" >
    </activity>
于 2013-10-11T05:15:51.763 回答
0

请像这样编辑您的Manifest.xml

    <activity
        android:name="com.ca.android.easycall.customers1"
        android:label="@string/title_activity_customers1" >
    </activity>
    <activity
        android:name="com.ca.android.easycall.customers2"
        android:label="@string/title_activity_customers2" >
    </activity>

我希望这有帮助。

于 2013-10-11T05:16:05.133 回答
0

检查活动文件顶部的包。也许活动的包与您的应用程序不同。

如果它不同,请将其更改为清单com.ca.android.easycall中的那个

于 2013-10-13T04:11:41.653 回答