当前位置: 首页 > 知识库问答 >
问题:

安卓应用启动后崩溃

袁奇文
2023-03-14

我正在尝试创建一个应用程序,有很多高清晰度的图像,这样他们就可以在高端设备和低端设备上工作。因为现在有的设备是手机,现在的分辨率是1080p。

我使用的是一个具有756MB内存、720p屏幕和我的VM堆大小为64MB的AVD。我的操作系统是Windows8。

这是我的activity档案。我现在没有添加任何内容

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
    }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

这是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:background="@drawable/bg"
tools:context=".MainActivity" >

 <ImageView
     android:id="@+id/head"
     android:layout_width="match_parent"
     android:layout_height="100dp"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
     android:scaleType="fitXY"
     android:src="@drawable/head1" />

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:weightSum="6" >

<ImageView
    android:id="@+id/logo"
    android:layout_width="0dp"
    android:layout_height="100dp"
    android:src="@drawable/logo21"
    android:layout_weight="3" />

<ImageView
    android:id="@+id/knob1"
    android:layout_width="0dp"
    android:layout_height="100dp"
    android:src="@drawable/knob1"
    android:layout_weight="1" />

<ImageView
    android:id="@+id/knob2"
    android:layout_width="0dp"
    android:layout_height="100dp"
    android:src="@drawable/knob2"
    android:layout_weight="1" />

<ImageView
    android:id="@+id/knob3"
    android:layout_width="0dp"
    android:layout_height="100dp"
    android:src="@drawable/knob3"
    android:layout_weight="1" />   

    </LinearLayout>

<ImageView
    android:id="@+id/bottom"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:paddingTop="10dp"
    android:src="@drawable/button" />

null

在运行应用程序时,我会收到以下消息

“不幸德国洗衣店停摆了”

请帮帮我!!

**根据请求更新我的logcat**


06-30 10:49:42.524: E/Trace(830): error opening trace file: No such file or directory (2)
06-30 10:49:43.063: D/dalvikvm(830): GC_FOR_ALLOC freed 41K, 7% free 2498K/2660K, paused 88ms, total 102ms
06-30 10:49:43.163: I/dalvikvm-heap(830): Grow heap (frag case) to 7.018MB for 4680016-byte allocation
06-30 10:49:43.264: D/dalvikvm(830): GC_FOR_ALLOC freed 2K, 3% free 7066K/7232K, paused 98ms, total 98ms
06-30 10:49:43.393: D/dalvikvm(830): GC_CONCURRENT freed (ImageView.java:120)
06-30 10:49:45.953: I/dalvikvm(830):   at android.widget.ImageView.(ImageView.java:110)
06-30 10:49:45.953: I/dalvikvm(830):   at java.lang.reflect.Constructor.constructNative(Native Method)
06-30 10:49:45.953: I/dalvikvm(830):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-30 10:49:45.963: I/dalvikvm(830):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)

06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-30 10:49:45.963: I/dalvikvm(830):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-30 10:49:45.963: I/dalvikvm(830):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.Activity.setContentView(Activity.java:1881)
06-30 10:49:45.963: I/dalvikvm(830):   at com.example.germanlaundryfinal.MainActivity.onCreate(MainActivity.java:12)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.Activity.performCreate(Activity.java:5104)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-30 10:49:45.963: I/dalvikvm(830):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-30 10:49:45.973: I/dalvikvm(830):   at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 10:49:45.973: I/dalvikvm(830):   at android.os.Looper.loop(Looper.java:137)
06-30 10:49:45.973: I/dalvikvm(830):   at android.app.ActivityThread.main(ActivityThread.java:5041)
06-30 10:49:45.973: I/dalvikvm(830):   at java.lang.reflect.Method.invokeNative(Native Method)
06-30 10:49:45.973: I/dalvikvm(830):   at java.lang.reflect.Method.invoke(Method.java:511)
06-30 10:49:45.973: I/dalvikvm(830):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-30 10:49:45.973: I/dalvikvm(830):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-30 10:49:45.973: I/dalvikvm(830):   at dalvik.system.NativeStart.main(Native Method)
06-30 10:49:45.973: D/skia(830): --- allocation failed for scaled bitmap
06-30 10:49:45.983: D/AndroidRuntime(830): Shutting down VM
06-30 10:49:45.983: W/dalvikvm(830): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-30 10:49:46.043: E/AndroidRuntime(830): FATAL EXCEPTION: main
06-30 10:49:46.043: E/AndroidRuntime(830): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.germanlaundryfinal/com.example.germanlaundryfinal.MainActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class 
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.os.Looper.loop(Looper.java:137)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread.main(ActivityThread.java:5041)
06-30 10:49:46.043: E/AndroidRuntime(830):  at java.lang.reflect.Method.invokeNative(Native Method)
06-30 10:49:46.043: E/AndroidRuntime(830):  at java.lang.reflect.Method.invoke(Method.java:511)
06-30 10:49:46.043: E/AndroidRuntime(830):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-30 10:49:46.043: E/AndroidRuntime(830):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-30 10:49:46.043: E/AndroidRuntime(830):  at dalvik.system.NativeStart.main(Native Method)
06-30 10:49:46.043: E/AndroidRuntime(830): Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class 
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
06-30 10:49:46.043: E/AndroidRuntime(830):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-30 10:49:46.043: E/AndroidRuntime(830):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.Activity.setContentView(Activity.java:1881)
06-30 10:49:46.043: E/AndroidRuntime(830):  at com.example.germanlaundryfinal.MainActivity.onCreate(MainActivity.java:12)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.Activity.performCreate(Activity.java:5104)
06-30 10:49:46.043: E/AndroidRuntime(830):  at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-30 10:49:46.043: E/AndroidRuntime(830):  ... 11 more
06-30 10:49:46.043: E/AndroidRuntime(830): Caused by: java.lang.reflect.InvocationTargetException
06-30 10:49:46.043: E/AndroidRuntime(830):  at java.lang.reflect.Constructor.constructNative(Native Method)
06-30 10:49:46.043: E/AndroidRuntime(830):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-30 10:49:46.043: E/AndroidRuntime(830):  ... 25 more
06-30 10:49:46.043: E/AndroidRuntime(830): Caused by: java.lang.OutOfMemoryError
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.content.res.Resources.loadDrawable(Resources.java:1965)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.widget.ImageView.(ImageView.java:120)
06-30 10:49:46.043: E/AndroidRuntime(830):  at android.widget.ImageView.(ImageView.java:110)
06-30 10:49:46.043: E/AndroidRuntime(830):  ... 28 more

共有1个答案

裴曜灿
2023-03-14

您必须缩放位图以使其在设备中正常工作。看这个答案。

 类似资料:
  • 我最近把一个应用程序上传到谷歌play商店,一切正常。我下载了它,并能够注册一个新用户。加载应用程序的主要活动时,应用程序崩溃。 这是我得到的stacktrace: 以前可能有人问过这个问题,但我已经研究了很多次,没有找到解决这个问题的方法。任何帮助都将不胜感激。该应用程序是使用android java和firebase创建的。

  • 问题内容: 每次我从Eclipse导出签名应用程序并将apk文件安装到手机上时,该应用程序都会崩溃。这仅在启用Proguard的情况下发生。 这是我的保护文件 我运行了adb logcat命令来检查崩溃报告。以下是我认为很重要的报告摘要: 第二段: 如果有人可以帮助我,我将非常感谢并接受您的回答。 更新: 所以我将这些添加到我的proguard文件中 现在启用Proguard时出现与Jackson

  • 问题是,当我在Google中使用授权运行此代码时,它会立即崩溃: 但是日志中的错误: 2019-06-22 17:55:42.652 29327-23222/?E/AudioSource:在已关闭的AudioSource 2019-06-22 17:55:43.240 2093-2616/?E/TouchFilter:setTouchFilter日志启用参数:0 2019-06-22 17:55:

  • 我的应用程序在我试图实现的闪屏后崩溃。我不知道问题发生在哪里。 我试着用两个小时来解决这个问题,甚至还研究了一下网络,但不知怎么的,我没能让它工作。也许你们可以看看代码,给我一些提示?我会很感激的。 AndroidManifest。xml launch_screen.xml activity_main.xml 风格。xml 主要活动。JAVA 所以会显示实际的启动屏幕,但之后应用程序就会崩溃。我不

  • 我试图将一个简单的SpringMVC REST API部署到Heroku--我在GitHub上有示例代码。当我部署到Heroku时,应用程序不工作--这是我在Heroku上的日志文件中看到的: 有没有一个地方我可以获得更多关于Heroku上出了什么问题的信息?我正在使用“GitHub部署”管道部署应用程序。

  • 使用活动的风险和对策取决于活动的使用方式。 在本节中,我们根据活动的使用情况,对 4 种活动进行了分类。 你可以通过下面的图表来找出,你应该创建哪种类型的活动。