ImageView和ImageButtons崩溃应用程序 - Android

时间:2014-05-14 12:32:20

标签: android

我有一个包含图像视图和图像按钮的xml文件,在我的java中,我只是引用布局,我甚至没有实例化任何对象,并且应用程序崩溃时出现以下错误:

05-14 08:07:40.637: E/AndroidRuntime(2223): FATAL EXCEPTION: main
05-14 08:07:40.637: E/AndroidRuntime(2223): Process: me.docci.natter, PID: 2223
05-14 08:07:40.637: E/AndroidRuntime(2223): java.lang.RuntimeException: Unable to start activity     ComponentInfo{me.docci.natter/me.docci.natter.Login}: android.view.InflateException: Binary XML file line #44: Error inflating class <unknown>
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.os.Looper.loop(Looper.java:136)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread.main(ActivityThread.java:5017)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at java.lang.reflect.Method.invokeNative(Native Method)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at java.lang.reflect.Method.invoke(Method.java:515)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at dalvik.system.NativeStart.main(Native Method)
05-14 08:07:40.637: E/AndroidRuntime(2223): Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class <unknown>
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.Activity.setContentView(Activity.java:1929)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at me.docci.natter.Login.onCreate(Login.java:12)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.Activity.performCreate(Activity.java:5231)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-14 08:07:40.637: E/AndroidRuntime(2223):     ... 11 more
05-14 08:07:40.637: E/AndroidRuntime(2223): Caused by: java.lang.reflect.InvocationTargetException
05-14 08:07:40.637: E/AndroidRuntime(2223):     at java.lang.reflect.Constructor.constructNative(Native Method)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
05-14 08:07:40.637: E/AndroidRuntime(2223):     ... 25 more
05-14 08:07:40.637: E/AndroidRuntime(2223): Caused by: java.lang.OutOfMemoryError
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.content.res.Resources.loadDrawable(Resources.java:2110)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.widget.ImageView.<init>(ImageView.java:129)
05-14 08:07:40.637: E/AndroidRuntime(2223):     at android.widget.ImageView.<init>    (ImageView.java:119)
05-14 08:07:40.637: E/AndroidRuntime(2223):     ... 28 more

和xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background_stripe"
android:gravity="center">
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center">
<ImageView
    android:id="@+id/ivSmallLogo"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:src="@drawable/logo_small"
    android:layout_marginBottom="50dp" />

                                                                                            

和java:

public class Login extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
}
}

1 个答案:

答案 0 :(得分:-1)

感谢Blackbelt我已经发现它是我正在使用的文件的大小(以kb为单位)。所以我减少了它们并且工作正常!谢谢!