Он уже скомпилирован и APK установлен. Но когда я пытаюсь открыть его на своем телефоне Android, он продолжает принудительно закрываться.
Я пробовал на нескольких устройствах, думая, что проблема в версии Android для телефона, но я не думаю, что это настоящая проблема.
MainActivity.java
package com.example.androideatit;
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(),"fonts/NABILA.TTF");
txtSlogan.setTypeface(face);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
}
Main_Activity.xml
<?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/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/logo_eat_it"
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:orientation = "horizontal"
android:layout_alignParentBottom = "true"
android:weightSum = "2"
android:layout_width = "match_parent"
android:layout_height = "wrap_content">
<info.hoang8f.widget.FButton
android:id = "@+id/btnSignUp"
android:text = "Sign Up"
android:textColor = "@android:color/white"
android:layout_weight = "1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
android:layout_margin = "8dp"
app:buttonColor = "@color/btnSignUp"
app:shadowColor = "@android:color/black"
app:shadowEnabled = "true"
app:shadowHeight = "5dp"
app:cornerRadius = "4dp"
/>
<info.hoang8f.widget.FButton
android:id = "@+id/btnSignIn"
android:text = "Sign In"
android:textColor = "@android:color/white"
android:layout_weight = "1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
android:layout_margin = "8dp"
app:buttonColor = "@color/btnSignActive"
app:shadowColor = "@android:color/black"
app:shadowEnabled = "true"
app:shadowHeight = "5dp"
app:cornerRadius = "4dp"
/>
</LinearLayout>
</RelativeLayout>
Android-логарифм
2019-04-03 07:11:03.874 32076-32076/? I/Zygote: seccomp disabled by setenforce 0
2019-04-03 07:11:03.861 32076-32076/? I/main: type=1400 audit(0.0:26974): avc: denied { read } for name = "u:object_r:bg_boot_complete_prop:s0" dev = "tmpfs" ino=17954 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:bg_boot_complete_prop:s0 tclass=file permissive=1
2019-04-03 07:11:03.861 32076-32076/? I/main: type=1400 audit(0.0:26975): avc: denied { read } for name = "u:object_r:bg_daemon_prop:s0" dev = "tmpfs" ino=17955 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:bg_daemon_prop:s0 tclass=file permissive=1
2019-04-03 07:11:03.861 32076-32076/? I/main: type=1400 audit(0.0:26976): avc: denied { read } for name = "u:object_r:bluetooth_a2dp_offload_prop:s0" dev = "tmpfs" ino=17956 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:bluetooth_a2dp_offload_prop:s0 tclass=file permissive=1
2019-04-03 07:11:03.861 32076-32076/? I/main: type=1400 audit(0.0:26977): avc: denied { read } for name = "u:object_r:bluetooth_prop:s0" dev = "tmpfs" ino=17957 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:bluetooth_prop:s0 tclass=file permissive=1
2019-04-03 07:11:03.861 32076-32076/? I/main: type=1400 audit(0.0:26978): avc: denied { read } for name = "u:object_r:bootloader_boot_reason_prop:s0" dev = "tmpfs" ino=17958 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:bootloader_boot_reason_prop:s0 tclass=file permissive=1
2019-04-03 07:11:03.881 32076-32076/? I/le.androideati: Late-enabling -Xcheck:jni
2019-04-03 07:11:03.959 32076-32083/? E/le.androideati: Failed to send DDMS packet REAQ to debugger (-1 of 20): Broken pipe
2019-04-03 07:11:04.260 32076-32076/? V/FA: Registered activity lifecycle callback
2019-04-03 07:11:04.274 32076-32076/? D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
2019-04-03 07:11:04.275 32076-32076/? D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
2019-04-03 07:11:04.275 32076-32076/? I/FirebaseInitProvider: FirebaseApp initialization successful
2019-04-03 07:11:04.321 32076-32098/? V/FA: Collection enabled
2019-04-03 07:11:04.321 32076-32098/? V/FA: App package, google app id: com.example.androideatit, 1:637601987854:android:d8941acf196c56e0
2019-04-03 07:11:04.322 32076-32098/? I/FA: App measurement is starting up, version: 15300
2019-04-03 07:11:04.322 32076-32098/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2019-04-03 07:11:04.322 32076-32098/? I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.androideatit
2019-04-03 07:11:04.322 32076-32098/? D/FA: Debug-level message logging enabled
2019-04-03 07:11:04.340 32076-32076/? V/FA: onActivityCreated
2019-04-03 07:11:04.358 32076-32098/? V/FA: Connecting to remote service
2019-04-03 07:11:04.376 32076-32076/? W/le.androideati: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2019-04-03 07:11:04.377 32076-32076/? W/le.androideati: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2019-04-03 07:11:04.394 32076-32098/? V/FA: Connection attempt already in progress
2019-04-03 07:11:04.439 32076-32076/? D/AndroidRuntime: Shutting down VM
--------- beginning of crash
2019-04-03 07:11:04.443 32076-32076/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androideatit, PID: 32076
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androideatit/com.example.androideatit.MainActivity}: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
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:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #37: 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 android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.androideatit.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
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:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
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:482)
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 android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.androideatit.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
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:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Я надеюсь, что он больше не будет принудительно закрываться. В настоящее время я просматриваю видеоруководство в https://thewikihow.com/video_Ad41Bh704ms&t=6s.




Внутри вашего макета вы используете
<info.hoang8f.widget.FButton
но в своей деятельности вы используете Button
также замените пространство имен app на fbutton
<info.hoang8f.widget.FButton
xmlns:fbutton = "http://schemas.android.com/apk/res-auto"
android:id = "@+id/btnSignUp"
android:text = "Sign Up"
android:textColor = "@android:color/white"
android:layout_weight = "1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
android:layout_margin = "8dp"
fbutton:buttonColor = "@color/btnSignUp"
fbutton:shadowColor = "@android:color/black"
fbutton:shadowEnabled = "true"
fbutton:shadowHeight = "5dp"
fbutton:cornerRadius = "4dp"
/>
<info.hoang8f.widget.FButton
xmlns:fbutton = "http://schemas.android.com/apk/res-auto"
android:id = "@+id/btnSignIn"
android:text = "Sign In"
android:textColor = "@android:color/white"
android:layout_weight = "1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
android:layout_margin = "8dp"
fbutton:buttonColor = "@color/btnSignActive"
fbutton:shadowColor = "@android:color/black"
fbutton:shadowEnabled = "true"
fbutton:shadowHeight = "5dp"
fbutton:cornerRadius = "4dp"
/>
Основная деятельность
FButton btnSignIn = (FButton)findViewById(R.id.btnSignIn);
FButton btnSignUp = (FButton)findViewById(R.id.btnSignUp);
@IlmiKalam смотрите обновленный ответ. также у вас есть два FButton в вашем xml. исправить их обоих
``` java.lang.RuntimeException: невозможно запустить активность 37: Ошибка при раздувании класса info.hoang8f.widget.FButton ```
@IlmiKalam, если вы скопировали эту библиотеку в свой проект, проверьте имя пакета библиотеки в вашем xml <info.hoang8f.widget.FButton, это должно быть то же имя пакета, что и ваша библиотека, иначе проблема в этой библиотеке, попробуйте заменить ее другой кнопкой
Большое спасибо за желание ответить на мой вопрос. Но означает ли это, что FButton вызывает принудительное закрытие?
Я ничего не копировал, я просто следил за всем в видео по этой ссылке youtube.com/watch?v=Ad41Bh704ms&t=6с
есть также эта вещь, которая происходит на уровне моего приложения Gradle. Все библиотеки com.android.support должны использовать одну и ту же спецификацию версии (смешение версий может привести к сбоям во время выполнения). Нашел версии 28.0.0, 26.1.0. Примеры включают com.android.support:animated-vector-drawable:28.0.0 и com.android.support:support-media-compat:26.1.0.
@IlmiKalam «Означает ли это, что FButton вызывает принудительное закрытие», принудительное закрытие определенно связано с этой библиотекой, вы можете заменить ее простой кнопкой библиотеки Android и протестировать
@IlmiKalam Я не думаю, что причиной этой ошибки является смешение версий библиотек.
Большое спасибо! Я просто выбираю использовать обычную кнопку. Нет больше ФК
проблема в строке 37 вашего макета
FButton