Virtual phone error : "App has stopped working"

Virtual phone error : "App has stopped working"

我有以下github项目

GITHUB file Project

每次我通过 android 工作室在虚拟 phone 上 运行 应用程序时,它都会出现 "App has stopped working"。我更新了 android 工作室。

logcat中不断出现的错误如下:

05.182 4961-4961/app.monmos E/AndroidRuntime: FATAL EXCEPTION: main
Process: app.monmos, PID: 4961
java.lang.RuntimeException: Unable to start activity ComponentInfo{app.monmos/app.monmos.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at app.monmos.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:473)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
at android.view.LayoutInflater.createView(LayoutInflater.java:647) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at app.monmos.MainActivity.onCreate(MainActivity.java:19) 
at android.app.Activity.performCreate(Activity.java:6999) 
at android.app.Activity.performCreate(Activity.java:6990) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

我也更新了 gradle 版本,但仍然没有任何效果。

<?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/backgroundimage"
tools:context="app.monmos.Signin">


<LinearLayout
    android:orientation="vertical"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_centerInParent="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout2">


<com.rengwuxian.materialedittext.MaterialAutoCompleteTextView
    android:id="@+id/edtphone"
    android:hint ="Phone Number"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text ="00000001"
    android:textColorHint="@android:color/white"
    android:textColor="@android:color/white"
    android:textSize="34sp"
    android:inputType="phone"
    app:met_baseColor="@android:color/white"
    app:met_floatingLabel="highlight"
    app:met_primaryColor="@android:color/white"
    app:met_singleLineEllipsis = "true"
    />



    <com.rengwuxian.materialedittext.MaterialAutoCompleteTextView
        android:id="@+id/edtPassword"
        android:hint ="Password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text ="1234"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:textSize="34sp"
        android:inputType="phone"
        app:met_baseColor="@android:color/white"
        app:met_floatingLabel="highlight"
        app:met_primaryColor="@android:color/white"
        app:met_singleLineEllipsis = "true"
        />
</LinearLayout>

    <info.hoang8f.widget.FButton
        android:id="@+id/btnSignIn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_weight="1"
        android:text="Sign In"
        android:textColor="@android:color/white"
        app:buttonColor="@color/btsSignActive"
        app:cornerRadius="4dp"
        app:shadowColor="@android:color/black"
        app:shadowEnabled="true"
        app:shadowHeight="5dp" />

//添加成绩文件

</RelativeLayout>

    // Top-level build file where you can add configuration options common to all sub-projects/modules.


buildscript {

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3' +
        '.0.1'
        classpath 'com.google.gms:google-services:3.1.0'


        // NOTE: Do not place your application dependencies here; they        belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

您没有在项目的 gradle 文件中设置 Maven。您的 gradle 文件应如下所示:

buildscript {
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}