在仿真器上强制关闭错误但在设备上没有

时间:2014-01-25 15:24:37

标签: android

我正在更改应用程序的布局。

我一直在我的设备上运行它,它工作得非常好。 但是,当我尝试在模拟器上运行时, 我崩溃了(给我力量关闭)。 我想知道为什么会这样。

我从logcat

得到了错误
   01-26 06:20:00.390: E/AndroidRuntime(854): FATAL EXCEPTION: main
01-26 06:20:00.390: E/AndroidRuntime(854): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fuellogproject/com.example.fuellogproject.homeActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.os.Looper.loop(Looper.java:137)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread.main(ActivityThread.java:5041)
01-26 06:20:00.390: E/AndroidRuntime(854):  at java.lang.reflect.Method.invokeNative(Native Method)
01-26 06:20:00.390: E/AndroidRuntime(854):  at java.lang.reflect.Method.invoke(Method.java:511)
01-26 06:20:00.390: E/AndroidRuntime(854):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-26 06:20:00.390: E/AndroidRuntime(854):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-26 06:20:00.390: E/AndroidRuntime(854):  at dalvik.system.NativeStart.main(Native Method)
01-26 06:20:00.390: E/AndroidRuntime(854): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
01-26 06:20:00.390: E/AndroidRuntime(854):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-26 06:20:00.390: E/AndroidRuntime(854):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.Activity.setContentView(Activity.java:1881)
01-26 06:20:00.390: E/AndroidRuntime(854):  at com.example.fuellogproject.homeActivity.onCreate(homeActivity.java:20)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.Activity.performCreate(Activity.java:5104)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-26 06:20:00.390: E/AndroidRuntime(854):  ... 11 more
01-26 06:20:00.390: E/AndroidRuntime(854): Caused by: java.lang.reflect.InvocationTargetException
01-26 06:20:00.390: E/AndroidRuntime(854):  at java.lang.reflect.Constructor.constructNative(Native Method)
01-26 06:20:00.390: E/AndroidRuntime(854):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-26 06:20:00.390: E/AndroidRuntime(854):  ... 23 more
01-26 06:20:00.390: E/AndroidRuntime(854): Caused by: java.lang.OutOfMemoryError
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.content.res.Resources.loadDrawable(Resources.java:1965)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.View.<init>(View.java:3330)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.View.<init>(View.java:3259)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.view.ViewGroup.<init>(ViewGroup.java:425)
01-26 06:20:00.390: E/AndroidRuntime(854):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
01-26 06:20:00.390: E/AndroidRuntime(854):  ... 26 more

homescreen.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
     android:background="@drawable/background"
   >



    <Button
        android:id="@+id/buttonLogIn"
         style="@style/CustomStyleButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:text="Enter" 
                  android:onClick="LogIn"
                  android:layout_above="@+id/buttonAbout"/>

    <Button
        android:id="@+id/buttonAbout"
        style="@style/CustomStyleButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="About" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:3)

  

引起:java.lang.OutOfMemoryError

为您的模拟器提供更多内存。另外请注意,android的版本为应用程序提供了不同的堆大小,因此如果您在模拟器上使用的设备与在设备上使用不同,那么它也可能是您的代码错误。

答案 1 :(得分:1)

请将hw.ramSize更改为hw.ramSize = 1024MB并执行以下操作:

hw.lcd.density = 160

sdcard.size = 300M

skin.path = 1280×800

skin.name = 1280×800

hw.cpu.arch =臂

abi.type = armeabi-V7A

hw.cpu.model = Cortex-A8的

vm.heapSize = 128

hw.ramSize = 1024MB

image.sysdir.1 =系统图像\机器人-16 \ armeabi-V7A \

希望有所帮助。