应用程序不断崩溃(不了解)| Android Studio |科特林

时间:2018-08-17 18:27:32

标签: android kotlin

我最近开始使用Android Studio,但突然我的应用崩溃了。我上次遇到此问题时,经过一番测试并指出了问题所在后,我能够将其修复。另一方面,这次我完全感到困惑,因为我的代码屏幕中有0个错误。我检查了Logcat,甚至对它一无所知。有人可以帮助我阅读此调试日志,以便我了解在哪里解决问题吗?

08-17 14:20:32.048 31768-31775/? E/art: Failed sending reply to debugger: Broken pipe 08-17 14:20:32.423 31768-31768/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mathe.trickytriviagame, PID: 31768
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mathe.trickytriviagame/com.example.mathe.trickytriviagame.HomePage}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2726)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6247)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
 Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
 Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at com.example.mathe.trickytriviagame.HomePage.onCreate(HomePage.kt:11)
    at android.app.Activity.performCreate(Activity.java:6757)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6247)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
 Caused by: java.lang.OutOfMemoryError: Failed to allocate a 307200012 byte allocation with 8388608 free bytes and 246MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
    at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:855)
    at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:706)
    at android.content.res.Resources.loadDrawable(Resources.java:863)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
    at android.view.View.<init>(View.java:4188)
    at android.view.ViewGroup.<init>(ViewGroup.java:578)
    at android.view.ViewGroup.<init>(ViewGroup.java:574)
    at android.view.ViewGroup.<init>(ViewGroup.java:570)
    at android.support.constraint.ConstraintLayout.<init>(ConstraintLayout.java:566)
        ... 23 more

1 个答案:

答案 0 :(得分:0)

从可绘制文件夹中调整布局图像src的大小,由于图像尺寸过大,应用程序崩溃,然后通常使图像尺寸减小。到