尝试构建 github 项目时出错

Getting errors trying to build a github project

我是 android 工作室的新人

我正在努力构建这个项目

https://github.com/CodingInfinite/AndroidLoginScreen

我修复了很多错误,但该应用仍然无法正常运行 运行

它打开并崩溃

这是错误

07-07 00:06:02.063 8601-8601/com.example.testdesign E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.testdesign, PID: 8601 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testdesign/com.example.testdesign.MainActivity}: android.view.InflateException: Binary XML file line #78: Binary XML file line #78: Error inflating class android.support.design.widget.TextInputEditText at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #78: Binary XML file line #78: Error inflating class android.support.design.widget.TextInputEditText at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.testdesign.MainActivity.onCreate(MainActivity.java:31) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class android.support.design.widget.TextInputEditText at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.example.testdesign.MainActivity.onCreate(MainActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6237)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputEditText" on path: DexPathList[[zip file "/data/app/com.example.testdesign-2/base.apk", zip file "/data/app/com.example.testdesign-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.testdesign-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.testdesign-2/lib/x86, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.view.LayoutInflater.createView(LayoutInflater.java:583) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)

显然错误就在这里

MainActivity.java

    package com.example.testdesign;

import android.animation.Animator;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.ViewPropertyAnimator;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;



import static android.view.View.GONE;
import static android.view.View.VISIBLE;

public class MainActivity extends AppCompatActivity {

    private ImageView bookIconImageView;
    private TextView bookITextView;
    private ProgressBar loadingProgressBar;
    private RelativeLayout rootView, afterAnimationView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        initViews();
        new CountDownTimer(5000, 1000) {

            @Override
            public void onTick(long millisUntilFinished) {
                bookITextView.setVisibility(GONE);
                loadingProgressBar.setVisibility(GONE);
                rootView.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSplashText));
                bookIconImageView.setImageResource(R.drawable.background_color_book);
                startAnimation();
            }

            @Override
            public void onFinish() {

            }
        }.start();
    }

    private void initViews() {
        bookIconImageView = findViewById(R.id.bookIconImageView);
        bookITextView = findViewById(R.id.bookITextView);
        loadingProgressBar = findViewById(R.id.loadingProgressBar);
        rootView = findViewById(R.id.rootView);
        afterAnimationView = findViewById(R.id.afterAnimationView);
    }

    private void startAnimation() {
        ViewPropertyAnimator viewPropertyAnimator = bookIconImageView.animate();
        viewPropertyAnimator.x(50f);
        viewPropertyAnimator.y(100f);
        viewPropertyAnimator.setDuration(1000);
        viewPropertyAnimator.setListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                afterAnimationView.setVisibility(VISIBLE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }

}

main_activity.xml

     <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rootView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/bookIconImageView"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:contentDescription="@null"
        android:src="@drawable/white_book_icon" />

    <TextView
        android:id="@+id/bookITextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/bookIconImageView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="5dp"
        android:text="@string/booki"
        android:textColor="@color/colorSplashText"
        android:textSize="16sp" />

    <ProgressBar
        android:id="@+id/loadingProgressBar"
        android:layout_width="match_parent"
        android:layout_height="12dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="-4dp"
        android:foregroundGravity="bottom"
        android:indeterminate="true"
        android:padding="0dp"
        android:theme="@style/ProgressBarStyle" />

    <RelativeLayout
        android:id="@+id/afterAnimationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="20dp"
        android:layout_marginTop="130dp"
        android:layout_marginEnd="20dp"
        android:visibility="gone">

        <TextView
            android:id="@+id/WelcomeTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/welcome_back"
            android:textColor="@color/colorBackground"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/readItTogetherTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/WelcomeTextView"
            android:layout_marginTop="10dp"
            android:text="@string/read_it_together"
            android:textColor="@color/colorAccent"
            android:textSize="15sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/loginButton"
            android:layout_below="@+id/readItTogetherTextView"
            android:gravity="center"
            android:orientation="vertical">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/emailEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/email"
                android:textColor="@color/colorTextView"
                android:textColorHint="@color/colorAccent"
                android:textSize="15sp" />

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/passwordEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:hint="@string/password"
                android:textColor="@color/colorTextView"
                android:textColorHint="@color/colorAccent"
                android:textSize="15sp" />

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:padding="5dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sign_up"
                    android:textColor="@color/colorTextView"
                    android:textSize="14sp"
                    android:textStyle="bold" />


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end|center_vertical"
                    android:text="@string/forget_password"
                    android:textColor="@color/colorTextView"
                    android:textSize="14sp"
                    android:textStyle="bold" />

            </FrameLayout>

        </LinearLayout>

        <Button
            android:id="@+id/loginButton"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:layout_above="@+id/skipTextView"
            android:layout_marginBottom="5dp"
            android:background="@drawable/button_drawable"
            android:text="@string/login"
            android:textAllCaps="false"
            android:textColor="@color/colorAccent"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/skipTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="10dp"
            android:background="?android:attr/selectableItemBackground"
            android:clickable="true"
            android:focusable="true"
            android:gravity="center"
            android:padding="12dp"
            android:text="@string/skip"
            android:textColor="@color/colorTextView"
            android:textSize="15sp" />


    </RelativeLayout>

</RelativeLayout>

build.gradle(应用程序)

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.testdesign"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:design:28.0.0'

}

API 23

ANDROID 工作室 3.4.1

首先,确保您具有 TextInputEditText 的依赖项。将此添加到依赖项下的 build.gradle(app):

implementation 'com.android.support:design:28.0.0'

接下来,将 AppCompatActivity 的导入更改为:

import android.support.v7.app.AppCompatActivity;

最后,将以下内容添加到 initViews 方法中的所有视图。将单词 this 放在所有 findViewById() 调用的前面。它们应该如下所示:

private void initViews() {
  bookIconImageView = this.findViewById(R.id.bookIconImageView);
  bookITextView = this.findViewById(R.id.bookITextView);
  loadingProgressBar = this.findViewById(R.id.loadingProgressBar);
  rootView = this.findViewById(R.id.rootView);
  afterAnimationView = this.findViewById(R.id.afterAnimationView);
}

希望这对你有用!这在我这边得到了 运行。

更新:

这是我能够从我的应用程序中获得的 build.gradle(app) 运行。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'
}




将 CountDownTimer 更改为

  new CountDownTimer(5000, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            bookITextView.setVisibility(GONE);
            loadingProgressBar.setVisibility(VISIBLE);
            bookIconImageView.setImageResource(R.drawable.white_book_icon);
            rootView.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorBackground));

        }

        @Override
        public void onFinish() {
            bookIconImageView.setImageResource(R.drawable.background_color_book);
            rootView.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSplashText));
            loadingProgressBar.setVisibility(GONE);
            startAnimation();

        }
    }.start();