java.lang.NoClassDefFoundError:失败的解析:Landroid / support / v4 / view / animation / FastOutSlowInInterpolator;

时间:2017-08-19 13:48:25

标签: java android android-layout

我的新应用程序遇到了问题。我创建了一个购物车应用程序,我创建了一个登录和注册页面,它现在显示错误消息

错误:

08-19 18:56:41.279 2902-2902/com.example.dinidev.ecom E/AndroidRuntime: FATAL EXCEPTION: main `Error`
                                                                    Process: com.example.dinidev.ecom, PID: 2902
                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dinidev.ecom/com.example.dinidev.ecom.Signin}: android.view.InflateException: Binary XML file line #32: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                     Caused by: android.view.InflateException: Binary XML file line #32: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
                                                                     Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
                                                                     Caused by: java.lang.reflect.InvocationTargetException
                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
                                                                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414)
                                                                        at android.app.Activity.setContentView(Activity.java:2414)
                                                                        at com.example.dinidev.ecom.Signin.onCreate(Signin.java:16)
                                                                        at android.app.Activity.performCreate(Activity.java:6662)
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/animation/FastOutSlowInInterpolator;
                                                                        at android.support.design.widget.AnimationUtils.<clinit>(AnimationUtils.java:30)
                                                                        at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:200)
                                                                        at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:183)
                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method) 
                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 
                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
                                                                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
                                                                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
                                                                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) 
                                                                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
                                                                        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414) 
                                                                        at android.app.Activity.setContentView(Activity.java:2414) 
                                                                        at com.example.dinidev.ecom.Signin.onCreate(Signin.java:16) 
                                                                        at android.app.Activity.performCreate(Activity.java:6662) 
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) 
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                        at android.os.Looper.loop(Looper.java:154) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
08-19 18:56:41.279 2902-2902/com.example.dinidev.ecom E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.animation.FastOutSlowInInterpolator" on path: DexPathList[[zip file "/data/app/com.example.dinidev.ecom-2/base.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.dinidev.ecom-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.dinidev.ecom-2/lib/x86, /system/lib, /vendor/lib]]
                                                                        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                            ... 30 more

模块应用:Build.gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
    applicationId "com.example.dinidev.ecom"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
     exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:multidex:1.0.1'

testCompile 'junit:junit:4.12'
}`Code`

activity_main xml It is opening and working properly

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/profile1"
tools:context="com.example.dinidev.ecom.MainActivity">


<Button
    android:id="@+id/guest"
    android:layout_width="168dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/signin"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="31dp"
    android:background="@android:color/holo_blue_light"
    android:clickable="true"
    android:text="@string/Guest_User"
    android:textColor="@color/white"
    android:textSize="@dimen/eighteen_sp"
    android:textStyle="bold"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_editor_absoluteY="487dp" />


<Button
    android:id="@+id/signin"
    android:layout_width="178dp"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/signup"
    android:layout_alignBottom="@+id/signup"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="12dp"
    android:layout_marginStart="12dp"
    android:background="@android:color/holo_blue_light"
    android:clickable="true"
    android:text="@string/login"
    android:textColor="@color/white"
    android:textSize="@dimen/eighteen_sp"
    android:textStyle="bold"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="487dp" />

<Button
    android:id="@+id/signup"
    android:layout_width="168dp"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="27dp"
    android:layout_marginEnd="12dp"
    android:layout_marginRight="12dp"
    android:background="@android:color/holo_blue_light"
    android:clickable="true"
    android:text="@string/New_User"
    android:textColor="@color/white"
    android:textSize="@dimen/eighteen_sp"
    android:textStyle="bold"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_editor_absoluteY="487dp" />
</RelativeLayout>

login_page xml It is not opening

<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/login_background">

    <TextView
        android:id="@+id/loginPage_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="@dimen/fourty_seven_dp"
        android:text="@string/logo"
        android:textColor="@color/white"
        android:textSize="@dimen/fourty_four_sp"
        android:textStyle="italic|bold"/>
</RelativeLayout> `It is not opening it shows error as app stopped working message`

MainActivity类

主要活动工作正常但是当我点击登录时它停止了行动

package com.example.dinidev.ecom;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button signin;
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    addListenerOnButton();
}

private void addListenerOnButton() {
    /** Login Button Click */
    signin = (Button) findViewById(R.id.signin);
    signin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, Signin.class);
            startActivity(intent);
        }
    });
 }

登录类

当我调试该行时,它显示了save instance:null message

package com.example.dinidev.ecom;
import android.app.Activity;
import android.os.Bundle;
public class Signin extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_page);
}
}

Androidmanifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dinidev.ecom">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:label="@string/register_label"
        android:name=".Signup">
    </activity>
    <activity
        android:label="@string/register_label"
        android:name=".Signin">
    </activity>

</application>

1 个答案:

答案 0 :(得分:0)

您必须在应用程序中包含multiDex。在您的清单中,您尚未包含 MulitiDexApplication

在您的错误代码中。看到这一行。

Didn't find class "android.support.v4.view.animation.FastOutSlowInInterpolator" on path: DexPathList[

将此添加到您的依赖项。

compile 'com.android.support:multidex:1.0.1'

在Gradle中添加multiDexEnabled true。

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true    // add this line
    }
    ...
}

manifest添加multiDex应用程序类中。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

最后清理并重建您的项目。

了解更多信息:https://developer.android.com/studio/build/multidex.html

希望有所帮助:)