这是堆栈跟踪:

06/26 15:42:08: Launching app
$ adb shell am start -n "com.virtual.ai/com.virtual.ai.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 19346 on device oneplus-oneplus_a6010-eb048141
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/m.Karbi.chonan: The ClassLoaderContext is a special shared library.
W/ActivityThread: Application com.virtual.ai can be debugged on port 8100...
I/Perf: Connecting to perf service.
V/FA: Registered activity lifecycle callback
D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
    com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
I/FirebaseInitProvider: FirebaseApp initialization successful
E/libc: Access denied finding property "vendor.debug.egl.profiler"
    Access denied finding property "vendor.debug.prerotation.disable"
W/com.virtual.ai: type=1400 audit(0.0:141094): avc: denied { read } for comm=45474C20496E6974 name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=22713 scontext=u:r:untrusted_app:s0:c88,c257,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
V/FA: Collection enabled
V/FA: App package, google app id: com.virtual.ai, 1:621374270923:android:1dc713bff6faa7cc
V/FA: onActivityCreated
I/FA: App measurement is starting up, version: 16250
    To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA: To enable faster debug mode event logging run:
      adb shell setprop debug.firebase.analytics.app com.virtual.ai
D/FA: Debug-level message logging enabled
W/m.virtual.ai: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/m.virtual.ai: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
V/FA: Connecting to remote service
V/FA: Connection attempt already in progress
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.virtual.ai, PID: 19346
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.virtual.ai/com.virtual.ai.MainActivity}: android.view.InflateException: Binary XML file line #43: Binary XML file line #43: Error inflating class info.hoang8f.widget.FButton
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6863)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.view.InflateException: Binary XML file line #43: Binary XML file line #43: Error inflating class info.hoang8f.widget.FButton
     Caused by: android.view.InflateException: Binary XML file line #43: 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:343)
        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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.virtual.ai.MainActivity.onCreate(MainActivity.java:20)
        at android.app.Activity.performCreate(Activity.java:7149)
        at android.app.Activity.performCreate(Activity.java:7140)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6863)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
        at android.content.res.TypedArray.getColor(TypedArray.java:501)
        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:343) 
        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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at com.virtual.ai.MainActivity.onCreate(MainActivity.java:20) 
        at android.app.Activity.performCreate(Activity.java:7149) 
        at android.app.Activity.performCreate(Activity.java:7140) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6863) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
W/OPDiagnose: getService:OPDiagnoseService NULL
D/OSTracker: OS Event: crash
I/Process: Sending signal. PID: 19346 SIG: 9
Application terminated.


我应该在这里做些改变吗?我得到的错误与构建版本有关。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.virtual.ai"
        minSdkVersion 15
        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 'com.google.firebase:firebase-core:16.0.9'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-core:10.2.0'
    implementation 'com.google.firebase:firebase-database:10.2.0'
    implementation 'info.hoang8f:fbutton:1.0.5'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.firebaseui:firebase-ui-database:1.2.0'
    implementation 'com.android.support:design:26.+'
    implementation "com.google.android.material:material:1.0.0"
    implementation "androidx.recyclerview:recyclerview:1.0.0"
    implementation "androidx.cardview:cardview:1.0.0"

}
apply plugin: 'com.google.gms.google-services'


这是main_activity.xml代码:




<LinearLayout
    android:layout_width="368dp"
    android:layout_height="583dp"
    android:layout_centerInParent="true"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:contentDescription="@string/des"
        android:src="@drawable/logo" />

    <TextView
        android:id="@+id/txtSlogan"
        android:layout_width="match_parent"
        android:layout_height="211dp"
        android:gravity="center"
        android:text="@string/slogan"
        android:textColor="@android:color/white" />


</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="85dp"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:weightSum="2">


    <info.hoang8f.widget.FButton
        android:id="@+id/btnSignUp"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:text="@string/SignUp"
        android:textColor="@android:color/white"
        app:buttonColor="@color/darkGreen"
        app:cornerRadius="4dp"
        app:shadowColor="@android:color/black"
        app:shadowEnabled="true"
        app:shadowHeight="2dp" />

    <info.hoang8f.widget.FButton
        android:id="@+id/btnSignIn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:text="@string/SignIn"
        android:textColor="@android:color/white"
        app:buttonColor="@color/lightGreen"
        app:cornerRadius="4dp"
        app:shadowColor="@android:color/black"
        app:shadowEnabled="true"
        app:shadowHeight="2dp" />

</LinearLayout>

最佳答案

这似乎是与info.hoang8f.widget.FButton有关的问题。
尝试将android gradle插件版本更改为2.3.3。
看看这个问题-Error inflating class info.hoang8f.widget.FButton

09-13 01:26