简体   繁体   English

应用程序在应用程序启动时崩溃并出现错误 java.lang.RuntimeException:

[英]App crashes on app start with error java.lang.RuntimeException:

I have some problem with device galaxy s5 and ImageButton - (On other devices it works good).我对设备galaxy s5 和ImageButton 有一些问题-(在其他设备上它运行良好)。

On my login activity i have ImageButton, so when I running app , it crashes.在我的登录活动中,我有 ImageButton,所以当我运行 app 时,它崩溃了。

Quistion updated: Added all the log from logcat问题更新:添加了来自 logcat 的所有日志

Here is a XML of the button - Starting from line 53这是按钮的 XML - 从第 53 行开始

<ImageButton
    android:id="@+id/btnNext"
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="150dp"
    android:background="@null"
    android:scaleType="fitCenter"
    app:srcCompat="@drawable/next_button" />

and Log:和日志:

02-01 16:54:58.392 11521-11521/com.enjoyapp.gettmarried E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.enjoyapp.gettmarried, PID: 11521
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.enjoyapp.gettmarried/com.enjoyapp.gettmarried.ui.activities.LoginActivity}: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class ImageButton
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
        at android.app.ActivityThread.access$1100(ActivityThread.java:221)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:7224)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
     Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class ImageButton
        at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
        at com.enjoyapp.gettmarried.ui.activities.LoginActivity.onCreate(LoginActivity.java:49)
        at android.app.Activity.performCreate(Activity.java:6876)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:158) 
        at android.app.ActivityThread.main(ActivityThread.java:7224) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
     Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class ImageButton
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
        at com.enjoyapp.gettmarried.ui.activities.LoginActivity.onCreate(LoginActivity.java:49) 
        at android.app.Activity.performCreate(Activity.java:6876) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:158) 
        at android.app.ActivityThread.main(ActivityThread.java:7224) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "com.enjoyapp.gettmarried:drawable/next_button" (7f06007e) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f06007e a=-1 r=0x7f06007e}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:4178)
        at android.content.res.Resources.loadDrawable(Resources.java:4085)
        at android.content.res.Resources.loadDrawable(Resources.java:3935)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:886)
        at android.widget.ImageView.<init>(ImageView.java:157)
        at android.widget.ImageButton.<init>(ImageButton.java:85)
        at android.widget.ImageButton.<init>(ImageButton.java:81)
        at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:73)
        at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:69)
        at androidx.appcompat.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:207)
        at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:123)
        at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
        at com.enjoyapp.gettmarried.ui.activities.LoginActivity.onCreate(LoginActivity.java:49) 
        at android.app.Activity.performCreate(Activity.java:6876) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:158) 
        at android.app.ActivityThread.main(ActivityThread.java:7224) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

Gradle :摇篮:

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.enjoyapp.gettmarried"
        minSdkVersion 23
        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'
        }
    }
}

Device info : Galaxy s5, android version - 6.0设备信息:Galaxy s5,安卓版本 - 6.0

Try with android:src instead of app:srcCompat .尝试使用android:src而不是app:srcCompat in set of your next button image.在您的下一个按钮图像中。 ;) ;)

I think I have found the problem:我想我已经发现了问题:

  Caused by: android.content.res.Resources$NotFoundException:
  Resource"com.enjoyapp.gettmarried:drawable/next_button" (7f06007e) is not a 
  Drawable (color or path): TypedValue{t=0x1/d=0x7f06007e a=-1 r=0x7f06007e}

Pay attention to your next_button or change srcCompat to src or background .注意你的next_button或将srcCompat更改为srcbackground

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 应用程序崩溃与java.lang.RuntimeException:无法启动活动ComponentInfo错误 - App crashes with java.lang.RuntimeException: Unable to start activity ComponentInfo error Android 应用程序 java.lang.RuntimeException 错误 - Android app java.lang.RuntimeException error 在我的应用程序中获取错误“java.lang.RuntimeException:无法启动活动” - Getting error “java.lang.RuntimeException: Unable to start activity” in my app 错误:java.lang.RuntimeException:Proguard-版本(app:transformClassesAndResourcesWithProguardForRelease) - Error:java.lang.RuntimeException: proguard - release (app:transformClassesAndResourcesWithProguardForRelease) “不幸的是,应用程序已停止” java.lang.RuntimeException:无法启动活动 ComponentInfo CAMERA APP - "Unfortunately, app has stopped" java.lang.RuntimeException: Unable to start activity ComponentInfo CAMERA APP 错误/ AndroidRuntime(219):java.lang.RuntimeException:无法启动活动ComponentInfo {elf.app/elf.app.RoomInfoActivity}:java.lang.NullP - ERROR/AndroidRuntime(219): java.lang.RuntimeException: Unable to start activity ComponentInfo{elf.app/elf.app.RoomInfoActivity}: java.lang.NullP java.lang.RuntimeException:无法启动活动ComponentIn}:.support.v7.app.ActionBarActivity - java.lang.RuntimeException: Unable to start activity ComponentIn}: .support.v7.app.ActionBarActivity Tomcat 7无法启动Web App,并抛出java.lang.RuntimeException:StackMapType的类型非法:-89 - Tomcat 7 failed to start Web App and threw java.lang.RuntimeException: Illegal type for StackMapType: -89 错误java.lang.RuntimeException:无法启动活动 - Error java.lang.RuntimeException: Unable to start activity Java.lang.RuntimeException:无法启动Android中的活动ComponentInfo错误 - Java.lang.RuntimeException: Unable to start activity ComponentInfo Error in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM