在Lollipop下面获取NoClassDefFoundError

时间:2015-08-26 09:55:56

标签: java android android-studio

我正在使用Android Studio 1.3。我安装了最新的SDK( 23 ),之后我在运行时出现了一些错误 android.view.InflateException NoClassDefFoundError 。这些错误在Lollipop中不会发生,但它们会在Kitkat上发生。

在安装SDK 23之前,我没有在Kitkat设备上收到任何错误。

现在我的构建gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    defaultConfig {
        applicationId "com.nanonino.notifeye"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        compileOptions {

            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':library')
    compile project(':Materialtimepicker')
    compile project(':main')
    compile project(':library1')
    compile 'com.google.android.gms:play-services:+'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:cardview-v7:23.+'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
}

错误日志

08-28 15:16:30.012  29750-29750/com.nanonino.notifeye E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.nanonino.notifeye, PID: 29750
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nanonino.notifeye/com.nanonino.notifeye.signup_login.SignuporLoginActivity}: android.view.InflateException: Binary XML file line #71: Error inflating class com.nanonino.notifeye.Utills.TypefacedTextViewrlight
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2235)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2285)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1236)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5077)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #71: Error inflating class com.nanonino.notifeye.Utills.TypefacedTextViewrlight
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
            at android.app.Activity.setContentView(Activity.java:1995)
            at com.nanonino.notifeye.signup_login.SignuporLoginActivity.onCreate(SignuporLoginActivity.java:86)
            at android.app.Activity.performCreate(Activity.java:5395)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2285)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1236)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5077)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)

有谁可以帮我解决这个问题?

这是我的 TypefacedTextViewrlight.java

package com.nanonino.notifeye.Utills;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

public class TypefacedTextViewrlight extends TextView {

    public TypefacedTextViewrlight(Context context) {
        super(context);
        style(context);
    }

    public TypefacedTextViewrlight(Context context, AttributeSet attrs) {
        super(context, attrs);
        style(context);
    }

    public TypefacedTextViewrlight(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        style(context);
    }

    private void style(Context context) {
        Typeface tf = Typeface.createFromAsset(context.getAssets(),
                "Roboto-Light.ttf");
        setTypeface(tf);
    }

}

以下是我的xml文件( activity_signuporlogin.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical">


    <RelativeLayout
        android:id="@+id/relativelayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:visibility="visible">

        <TextView
            android:id="@+id/Takeatour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:gravity="center"
            android:text="TAKE A TOUR"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#78B452"
            android:textStyle="bold"
            android:visibility="invisible" />

        <Button
            android:id="@+id/btnSignup"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_below="@+id/Takeatour"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/blackbackgroundbutton"
            android:text="START YOUR 30-DAY FREE TRIAL"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#ffffff"
            android:visibility="invisible" />

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/btnSignup"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:visibility="invisible">

            <View
                android:id="@+id/view1"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:background="#B3B3B3" />

            <com.nanonino.notifeye.Utills.TypefacedTextViewrlight
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="  OR  "
                android:textColor="#808080" />

            <View
                android:id="@+id/view2"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:background="#B3B3B3" />
        </LinearLayout>

        <Button
            android:id="@+id/subscribe"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_below="@+id/linearLayout1"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/orangebackgroundbutton"
            android:text="SUBSCRIBE NOW"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#ffffff"
            android:visibility="invisible" />

        <Button
            android:id="@+id/txtLogin"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_below="@+id/subscribe"
            android:layout_marginBottom="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/emailbuttonpressed"
            android:text="ALREADY REGISTERED? LOG IN"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#ffffff"
            android:visibility="invisible" />
    </RelativeLayout>

    <ImageView
        android:id="@+id/ivLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/relativelayout"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/logo"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/relativelayout"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/logo"
        android:visibility="invisible" />

</RelativeLayout>

0 个答案:

没有答案