类CardView的ClassNotFoundException导致应用程序崩溃

时间:2016-08-31 07:12:17

标签: android classnotfoundexception android-cardview

以下是ClassNotFoundException的代码段导致应用崩溃:

FATAL EXCEPTION: main 08-31 02:56:21.340: E/AndroidRuntime(1873): Process: com.lic.smarttab, PID:  E/AndroidRuntime(1873): android.view.InflateException: Binary XML file line #2: Error inflating class android.cardview

08-31 02:56:21.290: W/dalvikvm(1873): threadid=1: thread exiting with uncaught exception (group=0x94cd1b20)
08-31 02:56:21.340: E/AndroidRuntime(1873): FATAL EXCEPTION: main
08-31 02:56:21.340: E/AndroidRuntime(1873): Process: com.lic.smarttab, PID: 1873
08-31 02:56:21.340: E/AndroidRuntime(1873): android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.CardView
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at com.lic.smarttab.AbtOzarAdapter.getView(AbtOzarAdapter.java:58)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.widget.AbsListView.obtainView(AbsListView.java:2263)
08-31 02:56:21.340: E/AndroidRuntime(1873):     ... 24 more
08-31 02:56:21.340: E/AndroidRuntime(1873): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.CardView" on path: DexPathList[[zip file "/data/app/com.lic.smarttab-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.lic.smarttab-1, /system/lib]]
08-31 02:56:21.340: E/AndroidRuntime(1873):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
08-31 02:56:21.340: E/AndroidRuntime(1873):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
08-31 02:56:21.340: E/AndroidRuntime(1873):     ... 38 more

并且下面是清单文件

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="23" />

    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.lic.smarttab.permission.C2D_MESSAGE" />

    <permission
        android:name="com.lic.smarttab.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />

    <!-- To retrieve the account name (email) as part of sign-in: -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <!-- To auto-complete the email text field in the login form with the user's emails -->
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="Smart Tab"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <receiver
            android:name=".GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.lic.smarttab" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMNotificationIntentService" />

        <activity
            android:name=".Splash"
            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=".ActivityPlan838"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity838Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation838"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan833"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity833Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation833"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan818"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity818Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation818"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan189"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity189Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation189"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan827"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity827Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation827"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan820"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity820Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation820"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan821"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity821Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation821"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan822"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".ActivityPlan823"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity822Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity823Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation822And823"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan837"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity837Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation837"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan814"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity814Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation814"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan834"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity834Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation834"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan832"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity832Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation832"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan817"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity817Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation817"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan816"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity816Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation816"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ActivityPlan815"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Activity815Benefit"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait" />
        <activity
            android:name=".Presentation815"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".Home"
            android:label="@string/title_activity_home" >
        </activity>
        <activity
            android:name=".PremiumCalcPlanDetails"
            android:label="@string/title_activity_home" >
        </activity>
        <activity
            android:name=".ListServices"
            android:label="@string/title_activity_list_services" >
        </activity>
        <activity
            android:name=".NewUser"
            android:label="@string/title_activity_new_user" >
        </activity>
        <activity
            android:name=".Online_Facility"
            android:label="@string/title_activity_new_user" >
        </activity>
        <activity
            android:name=".MyPlans"
            android:label="@string/title_activity_my_plans" >
        </activity>
        <activity
            android:name=".PremiumCalc"
            android:label="@string/title_activity_premium_calc" >
        </activity>
        <activity
            android:name=".PlanDetails"
            android:label="@string/title_activity_plan_details" >
        </activity>
        <activity
            android:name=".AddNewPlan"
            android:label="@string/title_activity_add_new_plan" >
        </activity>
        <activity
            android:name=".PolicyServicing"
            android:label="@string/title_activity_policy_servicing" >
        </activity>
        <activity
            android:name=".NewPolicyEntry"
            android:label="@string/title_activity_new_policy_entry" >
        </activity>
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login"
            android:windowSoftInputMode="adjustResize|stateHidden" >
        </activity>

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".PolicySearch"
            android:label="@string/title_activity_policy_search" >
        </activity>
        <activity
            android:name=".PolicySearchResult"
            android:label="@string/title_activity_policy_search_result" >
        </activity>
        <activity
            android:name=".ServicingReports"
            android:label="@string/title_activity_servicing_reports" >
        </activity>
        <activity
            android:name=".ServicingReportsValue"
            android:label="@string/title_activity_servicing_reports_value" >
        </activity>
        <activity
            android:name=".UpdateData"
            android:label="@string/title_activity_update_data" >
        </activity>
        <activity
            android:name=".PolicyUpdateMbl"
            android:label="@string/title_activity_policy_update_mbl" >
        </activity>
        <activity
            android:name=".NBDownload"
            android:label="@string/title_activity_nbdownload" >
        </activity>
        <activity
            android:name=".NBDownloadSaveHug"
            android:label="@string/title_activity_nbdownload_save_hug" >
        </activity>
        <activity
            android:name=".DownloadNBDtata"
            android:label="@string/title_activity_download_nbdtata" >
        </activity>
        <activity
            android:name=".NBForm"
            android:label="@string/title_activity_nbform" >
        </activity>
        <activity
            android:name=".ImportUpdatePortalActivity"
            android:label="@string/title_activity_import_update_portal" >
        </activity>
        <activity
            android:name=".ActivityLastUpdateStats"
            android:label="@string/title_activity_activity_last_update_stats" >
        </activity>
        <activity
            android:name=".ClientInfoViewActivity"
            android:label="@string/title_activity_client_info_view" >
        </activity>
        <activity
            android:name=".ViewClientInfo"
            android:label="@string/title_activity_view_client_info" >
        </activity>
        <activity
            android:name=".ViewAllPolicyListview"
            android:label="@string/title_activity_view_all_policy_listview" >
        </activity>
        <activity
            android:name=".LapsedPolicies"
            android:label="@string/title_activity_lapsed_policies" >
        </activity>
        <activity
            android:name=".BirthdayListview_Offline"
            android:label="@string/title_activity_birthday_listview" >
        </activity>
        <activity
            android:name=".BirthdayListview"
            android:label="@string/title_activity_birthday_listview" >
        </activity>
        <activity
            android:name=".OutsatandingDuesListview"
            android:label="@string/title_activity_outsatanding_dues_listview" >
        </activity>
        <activity
            android:name=".SettingListview"
            android:label="@string/title_activity_setting_listview" >
        </activity>
        <activity
            android:name=".AgentPortal"
            android:label="@string/title_activity_agent_portal" >
        </activity>
        <activity
            android:name=".SMS_Setting"
            android:label="@string/title_activity_sms__setting" >
        </activity>
        <activity
            android:name=".OnlineFacilityWebview"
            android:label="@string/title_activity_online_facility_webview" >
        </activity>
        <activity
            android:name=".Plan838"
            android:label="@string/title_activity_plan838" >
        </activity>
        <activity
            android:name=".ListPlanCalc"
            android:label="@string/title_activity_list_plan_calc" >
        </activity>
        <activity
            android:name=".PolicyStatus"
            android:label="@string/title_activity_policy_status" >
        </activity>
        <activity
            android:name=".LoanStatus"
            android:label="@string/title_activity_loan_status" >
        </activity>
        <activity
            android:name=".NewClientPolicy"
            android:label="@string/title_activity_new_client_policy" >
        </activity>
        <activity
            android:name=".ActivityNewClient"
            android:label="@string/title_activity_activity_new_client" >
        </activity>
    </application>

</manifest>

布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:background="#FFFFFF"
    card_view:cardUseCompatPadding="true"
    card_view:cardElevation="4dp"
    card_view:cardCornerRadius="3dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:gravity="center"
        android:background="#FFFFFF"
        android:layout_marginTop="5dp"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imgGrid"
            android:layout_width="160dp"
            android:layout_height="160dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10dp"
            android:background="#FFFFFF"
            android:contentDescription="@null"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/txtGrid"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="3dp"
            android:layout_marginTop="5dp"
            android:gravity="center|bottom"
            android:text="gggg"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#056839"
            android:textStyle="bold" >

    </TextView>


    </LinearLayout>
</android.support.v7.widget.CardView>

我已将cardview和google play服务作为同一工作区中的库项目进行链接。

1 个答案:

答案 0 :(得分:1)

class not found exceptionCardView。这将帮助您解决问题。在ecllipse中,您必须手动导入项目

  1. CardView的项目位于Android SDK文件夹中:Android \ android-sdk \ extras \ android \ support \ v7 \ cardview
  2. 在Eclipse中使用“导入”并选择“现有Android代码进入工作区”并导入CardView项目
  3. 转到新项目的Properties-&gt; Android,将其标记为库项目,然后将其链接为您自己项目中无法找到CardView的库项目