尝试构建github项目时遇到错误

时间:2019-07-07 00:16:43

标签: android android-design-library

我是android studio的新手

我正在努力建立这个项目

https://github.com/CodingInfinite/AndroidLoginScreen

我遇到了很多我已修复的错误,但该应用仍然无法运行

打开并崩溃

这是错误

  

07-07 00:06:02.063 8601-8601 / com.example.testdesign E / Android运行时:致命异常:主要       流程:com.example.testdesign,PID:8601       java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.testdesign / com.example.testdesign.MainActivity}:android.view.InflateException:二进制XML文件行#78:二进制XML文件行#78:错误夸大类android.support.design.widget.TextInputEditText           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)           在android.app.ActivityThread.-wrap11(ActivityThread.java)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:148)           在android.app.ActivityThread.main(ActivityThread.java:5417)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)        原因:android.view.InflateException:二进制XML文件第78行:二进制XML文件第78行:错误膨胀了类android.support.design.widget.TextInputEditText           在android.view.LayoutInflater.inflate(LayoutInflater.java:539)           在android.view.LayoutInflater.inflate(LayoutInflater.java:423)           在android.view.LayoutInflater.inflate(LayoutInflater.java:374)           在androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)           在androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)           在com.example.testdesign.MainActivity.onCreate(MainActivity.java:31)           在android.app.Activity.performCreate(Activity.java:6237)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)           在android.app.ActivityThread.-wrap11(ActivityThread.java)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:148)           在android.app.ActivityThread.main(ActivityThread.java:5417)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)        原因:android.view.InflateException:二进制XML文件行#78:错误膨胀了类android.support.design.widget.TextInputEditText           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)           在android.view.LayoutInflater.rInflate(LayoutInflater.java:835)           在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)           在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)           在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)           在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)           在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)           在android.view.LayoutInflater.inflate(LayoutInflater.java:515)           在android.view.LayoutInflater.inflate(LayoutInflater.java:423)           在android.view.LayoutInflater.inflate(LayoutInflater.java:374)           在androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)           在androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)           在com.example.testdesign.MainActivity.onCreate(MainActivity.java:31)           在android.app.Activity.performCreate(Activity.java:6237)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)           在android.app.ActivityThread.-wrap11(ActivityThread.java)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:148)           在android.app.ActivityThread.main(ActivityThread.java:5417)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)        原因:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件“ /data/app/com.example.testdesign-2/base.apk”中找不到类“ android.support.design.widget.TextInputEditText” ”,zip文件“ /data/app/com.example.testdesign-2/split_lib_dependencies_apk.apk”、zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_0_apk.apk”、zip文件“ / data / app / com.example.testdesign-2 / split_lib_slice_1_apk.apk”,zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_2_apk.apk”、zip文件“ /data/app/com.example.testdesign- 2 / split_lib_slice_3_apk.apk”,zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_4_apk.apk”、zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_5_apk.apk”、zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_6_apk.apk”,压缩文件“ /data/app/com.example.testdesign-2/split_lib_slice_7_apk.apk”,压缩文件“ / data / app / com .example.testdesign-2 / split_lib_slice_8_apk.apk“,zip文件“ /data/app/com.example.testdesign-2/split_lib_slice_9_apk.apk”],n ativeLibraryDirectories = [/ data / app / com.example.testdesign-2 / lib / x86,/ vendor / lib,/ system / lib]]           在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)           在java.lang.ClassLoader.loadClass(ClassLoader.java:511)           在java.lang.ClassLoader.loadClass(ClassLoader.java:469)           在android.view.LayoutInflater.createView(LayoutInflater.java:583)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)

所以显然错误在这里

enter image description here

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 STUDIO 3.4.1

3 个答案:

答案 0 :(得分:0)

首先,请确保您具有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'
}




答案 1 :(得分:0)

You got error with android.support.design.widget.TextInputEditText at 
       android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)

我认为您的设计库存在问题。迁移到androidx并使用此库:

  

实现'com.google.android.material:material:1.0.0'

尝试将主题更改为:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">

答案 2 :(得分: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();