无法找到活动,您是否已在清单中声明

时间:2016-09-10 08:27:39

标签: android

我正在尝试在我的应用中实现pdf viewer。

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

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/logo1"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
         android:name="com.example.ttech.SplashScreen"
        android:label="@string/title_activity_splash_screen"
        >
      <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.ttech.MainActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.ttech.NewLogin"
        android:label="@string/title_activity_new_login" >
    </activity>
    <activity
        android:name="com.example.ttech.HomePage"
        android:label="@string/title_activity_home_page" >
    </activity>
    <activity
        android:name="com.example.ttech.Audio"
        android:label="@string/title_activity_audio" >
    </activity>
   <activity android:name=".PdfViewerActivity"
        android:label="@string/title_activity_pdf_viewer"
        >
    </activity>
    <activity
        android:name="com.example.ttech.Feedback"
        android:label="@string/title_activity_feedback" >
    </activity>
    <activity
        android:name="com.example.ttech.Profile"
        android:label="@string/title_activity_profile" >
    </activity>
    <activity
        android:name="com.example.ttech.AboutUs"
        android:label="@string/title_activity_about_us" >
    </activity>
    <activity
        android:name="com.example.ttech.Contact"
        android:label="@string/title_activity_contact" >
    </activity>
    <activity
        android:name="com.example.ttech.LogOut"
        android:label="@string/title_activity_log_out" >
    </activity>
    <activity
         android:name="com.example.ttech.LoginActivity"
        android:label="@string/title_activity_login"
        >
    </activity>
</application>

我得到的错误是: -

E/AndroidRuntime(828): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.ttech/net.sf.andpdf.pdfviewer.PdfViewerActivity}; have you declared this activity in your Android manifest

1 个答案:

答案 0 :(得分:2)

您将活动声明为

<activity android:name=".PdfViewerActivity"
    android:label="@string/title_activity_pdf_viewer" />

由于您定义了package="com.example.ttech",因此该活动指向了班级com.example.ttech.PdfViewerActivity,但您希望改为使用net.sf.andpdf.pdfviewer.PdfViewerActivity

因此,您必须使用绝对包名称

定义活动
<activity android:name="net.sf.andpdf.pdfviewer.PdfViewerActivity"
    android:label="@string/title_activity_pdf_viewer" />