作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经编辑了splash.xml 文件,当我尝试运行应用程序时,出现“不幸的是应用程序已停止”错误。
在我编辑此 splash.xml 文件之前(应用程序运行时),该文件上有 2 个图像
我尝试重新运行 Eclipse 和模拟器,但还是出现同样的问题
这是原始的splash.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/main_bg"
android:gravity="center" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="180.0dip"
android:layout_height="180.0dip"
android:layout_below="@+id/imageView2"
android:layout_centerHorizontal="true"
android:src="@drawable/iconmain"
android:contentDescription="@string/app_name"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="180.0dip"
android:layout_height="105.0dip"
android:layout_alignLeft="@+id/imageView1"
android:layout_alignParentTop="true"
android:layout_marginTop="14.0dip"
android:src="@drawable/title"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
这是修改后的版本:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/main_bg"
android:gravity="center" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/applogofull"/>
</RelativeLayout>
这是 LogCat:
10-30 06:11:11.840: I/art(1961): Debugger is active
10-30 06:11:11.999: I/System.out(1961): Debugger has connected
10-30 06:11:11.999: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:12.203: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:12.403: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:12.603: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:12.803: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:13.004: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:13.204: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:13.404: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:13.605: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:13.805: I/System.out(1961): waiting for debugger to settle...
10-30 06:11:14.006: I/System.out(1961): debugger has settled (1485)
10-30 06:11:14.554: I/art(1961): Alloc sticky concurrent mark sweep GC freed 1724(90KB) AllocSpace objects, 0(0B) LOS objects, 26% free, 22MB/30MB, paused 289us total 37.744ms
10-30 06:11:14.560: I/art(1961): Alloc partial concurrent mark sweep GC freed 65(15KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 22MB/36MB, paused 491us total 5.432ms
10-30 06:11:14.569: I/art(1961): Alloc concurrent mark sweep GC freed 17(12KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 22MB/36MB, paused 402us total 9.377ms
10-30 06:11:14.570: I/art(1961): Forcing collection of SoftReferences for 462MB allocation
10-30 06:11:14.582: I/art(1961): Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 39% free, 22MB/36MB, paused 2.325ms total 12.381ms
10-30 06:11:14.582: E/art(1961): Throwing OutOfMemoryError "Failed to allocate a 485258948 byte allocation with 15447336 free bytes and 73MB until OOM"
10-30 06:11:14.600: I/art(1961): Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 39% free, 22MB/36MB, paused 1.374ms total 10.202ms
10-30 06:11:14.600: I/art(1961): Forcing collection of SoftReferences for 462MB allocation
10-30 06:11:14.609: I/art(1961): Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 39% free, 22MB/36MB, paused 788us total 8.989ms
10-30 06:11:14.610: E/art(1961): Throwing OutOfMemoryError "Failed to allocate a 485258948 byte allocation with 15447336 free bytes and 73MB until OOM"
10-30 06:11:14.610: D/skia(1961): --- allocation failed for scaled bitmap
10-30 06:11:14.613: D/AndroidRuntime(1961): Shutting down VM
10-30 06:11:14.619: E/AndroidRuntime(1961): FATAL EXCEPTION: main
10-30 06:11:14.619: E/AndroidRuntime(1961): Process: com.AbdellahASKI.SoundQuiz, PID: 1961
10-30 06:11:14.619: E/AndroidRuntime(1961): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.AbdellahASKI.SoundQuiz/com.AbdellahASKI.SoundQuiz.SplashActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.os.Handler.dispatchMessage(Handler.java:102)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.os.Looper.loop(Looper.java:135)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread.main(ActivityThread.java:5254)
10-30 06:11:14.619: E/AndroidRuntime(1961): at java.lang.reflect.Method.invoke(Native Method)
10-30 06:11:14.619: E/AndroidRuntime(1961): at java.lang.reflect.Method.invoke(Method.java:372)
10-30 06:11:14.619: E/AndroidRuntime(1961): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-30 06:11:14.619: E/AndroidRuntime(1961): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-30 06:11:14.619: E/AndroidRuntime(1961): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.createView(LayoutInflater.java:633)
10-30 06:11:14.619: E/AndroidRuntime(1961): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
10-30 06:11:14.619: E/AndroidRuntime(1961): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.Activity.setContentView(Activity.java:2145)
10-30 06:11:14.619: E/AndroidRuntime(1961): at com.AbdellahASKI.SoundQuiz.SplashActivity.onCreate(SplashActivity.java:20)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.Activity.performCreate(Activity.java:5990)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
10-30 06:11:14.619: E/AndroidRuntime(1961): ... 10 more
10-30 06:11:14.619: E/AndroidRuntime(1961): Caused by: java.lang.reflect.InvocationTargetException
10-30 06:11:14.619: E/AndroidRuntime(1961): at java.lang.reflect.Constructor.newInstance(Native Method)
10-30 06:11:14.619: E/AndroidRuntime(1961): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.view.LayoutInflater.createView(LayoutInflater.java:607)
10-30 06:11:14.619: E/AndroidRuntime(1961): ... 23 more
10-30 06:11:14.619: E/AndroidRuntime(1961): Caused by: java.lang.OutOfMemoryError: Failed to allocate a 485258948 byte allocation with 15447336 free bytes and 73MB until OOM
10-30 06:11:14.619: E/AndroidRuntime(1961): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.content.res.Resources.loadDrawable(Resources.java:2381)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.widget.ImageView.<init>(ImageView.java:146)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.widget.ImageView.<init>(ImageView.java:135)
10-30 06:11:14.619: E/AndroidRuntime(1961): at android.widget.ImageView.<init>(ImageView.java:131)
10-30 06:11:14.619: E/AndroidRuntime(1961): ... 26 more
感谢大家的帮助,但是当我优化图像并尝试运行应用程序时,我在控制台上收到另一个错误(最后一行是红色的):
[2015-10-30 13:50:45 - SoundQuiz] Dx Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
[2015-10-30 13:50:45 - SoundQuiz] Dx 1 error; aborting
[2015-10-30 13:50:45 - SoundQuiz] Conversion to Dalvik format failed with error 1
最佳答案
加载图像时超出了内存限制。也许太大了。
可能有不同的方法:
告诉系统应用将需要更多内存,编辑 list 以在 application
中添加 android:largeHeap="true"
<application
...
android:largeHeap="true" >
关于java - 不幸的是,在splash.xml上添加图像后应用程序已停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33426405/
我们有一个使用 Eclipse 和 Maven 的多模块项目。过去我能让它工作的唯一方法是对项目使用平面布局,其中父模块是其他模块的对等体。这适用于 m2eclipse 和 Subversion。 现
我是一名优秀的程序员,十分优秀!