每当我尝试启动它时,我的应用程序就会崩溃! 我正在尝试在手机上进行跑步 该应用已安装但无法启动 我只是用一个图片和2个按钮制作了一个简单的屏幕! 我试图更改布局,但仍然无法正常工作! 有人可以帮我吗? 谢谢!! 这是Logcat:
04-11 21:53:06.636 18950-18950/? I/art: Late-enabling -Xcheck:jni
04-11 21:53:07.256 18950-18950/com.example.myfoodorderapp V/FA: Registered activity lifecycle callback
04-11 21:53:07.256 18950-18950/com.example.myfoodorderapp D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
04-11 21:53:07.256 18950-18950/com.example.myfoodorderapp D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
04-11 21:53:07.266 18950-18950/com.example.myfoodorderapp I/FirebaseInitProvider: FirebaseApp initialization successful
04-11 21:53:07.266 18950-18950/com.example.myfoodorderapp I/InstantRun: starting instant run server: is main process
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp V/FA: Collection enabled
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp V/FA: App package, google app id: com.example.myfoodorderapp, 1:235236386201:android:38ab5093f7ffffb9
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp I/FA: App measurement is starting up, version: 12780
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.myfoodorderapp
04-11 21:53:07.376 18950-18994/com.example.myfoodorderapp D/FA: Debug-level message logging enabled
04-11 21:53:07.426 18950-18950/com.example.myfoodorderapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-11 21:53:07.476 18950-18994/com.example.myfoodorderapp V/FA: Connecting to remote service
04-11 21:53:07.486 18950-18950/com.example.myfoodorderapp V/FA: onActivityCreated
04-11 21:53:07.506 18950-18950/com.example.myfoodorderapp E/Process: android_os_Process_getProcessNameByPid pid is 18950
04-11 21:53:07.506 18950-18950/com.example.myfoodorderapp E/Process: android_os_Process_getProcessNameByPid value is .myfoodorderapp
04-11 21:53:07.556 18950-18994/com.example.myfoodorderapp V/FA: Connection attempt already in progress
04-11 21:53:08.016 18950-18950/com.example.myfoodorderapp D/AndroidRuntime: Shutting down VM
04-11 21:53:08.026 18950-18950/com.example.myfoodorderapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myfoodorderapp, PID: 18950
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfoodorderapp/com.example.myfoodorderapp.MainActivity}: android.view.InflateException: Binary XML file line #40: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5541)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: android.view.InflateException: Binary XML file line #40: Error inflating class info.hoang8f.widget.FButton
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.myfoodorderapp.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6093)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5541)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.myfoodorderapp.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6093)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5541)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:572)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:121)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.myfoodorderapp.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6093)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5541)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
04-11 21:53:08.346 18950-18950/? I/Process: Sending signal. PID: 18950 SIG: 9
04-11 21:53:08.346 18950-18950/? V/Process: killProcess [18950] Callers=com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException:99 java.lang.ThreadGroup.uncaughtException:693 java.lang.ThreadGroup.uncaughtException:690 <bottom of call stack>
这是xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:gravity="center"
android:background="@drawable/my_bg"
tools:context=".MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/as"
android:layout_width="200dp"
android:layout_height="200dp" />
<TextView
android:gravity="center"
android:id="@+id/txtSlogan"
android:text="@string/slogan"
android:textColor="@android:color/white"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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="Sign Up"
android:textColor="@android:color/white"
app:buttonColor="@color/btnSignUp"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp"
/>
<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="Sign In"
android:textColor="@android:color/white"
app:buttonColor="@color/btnSignActive"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp"
/>
</LinearLayout>
</LinearLayout>
这是java文件:
package com.example.myfoodorderapp;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button btnSignIn,btnSignUp;
TextView txtSlogan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSignIn=(Button)findViewById(R.id.btnSignIn);
btnSignUp=(Button)findViewById(R.id.btnSignUp);
txtSlogan=(TextView)findViewById(R.id.txtSlogan);
Typeface face=Typeface.createFromAsset(getAssets(),"font/NABILA.TTF");
txtSlogan.setTypeface(face);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
}
答案 0 :(得分:0)
尝试将以下数字从0更改为更高的数字
android:layout_width="0dp"
答案 1 :(得分:0)
这可能是由于info.hoang8f.widget.FButton
库中的一个已知错误。您可以在这里看到问题:https://github.com/hoang8f/android-flat-button/issues/41。
这是因为FButton类在第115行中使用了错误的属性命名:
else if (attr == R.styleable.FButton_buttonColor) {
...
}
此问题已在另一个分支中得到纠正:https://gitlab.com/RilixTechnology/android-flat-button或https://github.com/jd-alexander/android-flat-button
答案 2 :(得分:0)
您使用过的xml文件中的问题
<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="Sign Up"
android:textColor="@android:color/white"
app:buttonColor="@color/btnSignUp"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp"
/>
此小部件无法膨胀,请尝试对其进行修复或删除。