我无法理解这里的问题。我的Android应用程序根本不运行,这是logcat输出。
09-26 20:21:35.609 2540-2540/com.example.savag.myapplication I/art﹕ Not late-enabling -Xcheck:jni (already on)
09-26 20:21:35.609 2540-2540/com.example.savag.myapplication I/art﹕ Late-enabling JIT
09-26 20:21:35.646 2540-2540/com.example.savag.myapplication I/art﹕ JIT created with code_cache_capacity=2MB compile_threshold=1000
09-26 20:21:35.749 2540-2540/com.example.savag.myapplication W/System﹕ ClassLoader referenced unknown path: /data/app/com.example.savag.myapplication-2/lib/x86
09-26 20:21:36.804 2540-2551/com.example.savag.myapplication I/art﹕ Background sticky concurrent mark sweep GC freed 5990(393KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 10MB/10MB, paused 17.760ms total 60.005ms
09-26 20:21:36.886 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:36.886 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:36.906 2540-2540/com.example.savag.myapplication I/art﹕ Alloc sticky concurrent mark sweep GC freed 17(848B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.261ms total 18.538ms
09-26 20:21:36.910 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:36.965 2540-2540/com.example.savag.myapplication I/art﹕ Alloc partial concurrent mark sweep GC freed 18(784B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.299ms total 54.124ms
09-26 20:21:36.967 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:36.988 2540-2540/com.example.savag.myapplication I/art﹕ Alloc concurrent mark sweep GC freed 8(12KB) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.902ms total 19.329ms
09-26 20:21:36.989 2540-2540/com.example.savag.myapplication I/art﹕ Forcing collection of SoftReferences for 66MB allocation
09-26 20:21:36.991 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.011 2540-2540/com.example.savag.myapplication I/art﹕ Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.322ms total 19.763ms
09-26 20:21:37.013 2540-2540/com.example.savag.myapplication W/art﹕ Throwing OutOfMemoryError "Failed to allocate a 70056012 byte allocation with 4194304 free bytes and 46MB until OOM"
09-26 20:21:37.014 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.015 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.032 2540-2540/com.example.savag.myapplication I/art﹕ Alloc sticky concurrent mark sweep GC freed 3(560B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.341ms total 15.687ms
09-26 20:21:37.034 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.051 2540-2540/com.example.savag.myapplication I/art﹕ Alloc partial concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.313ms total 16.234ms
09-26 20:21:37.053 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.171 2540-2540/com.example.savag.myapplication I/art﹕ Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 26.229ms total 116.717ms
09-26 20:21:37.182 2540-2540/com.example.savag.myapplication I/art﹕ Forcing collection of SoftReferences for 66MB allocation
09-26 20:21:37.183 2540-2540/com.example.savag.myapplication I/art﹕ Starting a blocking GC Alloc
09-26 20:21:37.202 2540-2540/com.example.savag.myapplication I/art﹕ Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 18% free, 17MB/21MB, paused 2.250ms total 17.745ms
09-26 20:21:37.205 2540-2540/com.example.savag.myapplication W/art﹕ Throwing OutOfMemoryError "Failed to allocate a 70056012 byte allocation with 4194304 free bytes and 46MB until OOM"
09-26 20:21:37.206 2540-2540/com.example.savag.myapplication D/skia﹕ --- allocation failed for scaled bitmap
09-26 20:21:37.207 2540-2540/com.example.savag.myapplication D/AndroidRuntime﹕ Shutting down VM
09-26 20:21:37.207 2540-2540/com.example.savag.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.savag.myapplication, PID: 2540
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.savag.myapplication/com.example.savag.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #34: Binary XML file line #34: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #34: Binary XML file line #34: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.savag.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.savag.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.savag.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 70056012 byte allocation with 4194304 free bytes and 46MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2635)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.view.View.<init>(View.java:3948)
at android.view.ViewGroup.<init>(ViewGroup.java:573)
at android.widget.LinearLayout.<init>(LinearLayout.java:203)
at android.widget.LinearLayout.<init>(LinearLayout.java:199)
at android.widget.LinearLayout.<init>(LinearLayout.java:195)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.savag.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我认为我知道的错误之一,那与记忆有关,说实话我在屏幕上没有那么多,(我认为无论如何)我认为我需要做一些aysnc到克服了这个?其他人在不提出想法的情况下飞过我身边 请一些澄清。
添加了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:background="@drawable/tugsedit"
android:orientation="vertical"
android:gravity="bottom">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="25dp"
android:id="@+id/imageView"
android:layout_gravity="center_vertical"
android:background="@drawable/topbarmaincenter"
android:layout_marginTop="30dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton4" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="245dp"
android:background="@drawable/logoandbar4"
android:layout_gravity="bottom"
android:layout_marginBottom="6dp"
android:weightSum="1">
<ImageButton
android:layout_width="59dp"
android:layout_height="63dp"
android:id="@+id/imageButton"
android:layout_gravity="bottom"
android:background="@drawable/motionbuttonup"
android:layout_marginLeft="205dp"
android:layout_marginBottom="1dp" />
<ImageButton
android:layout_width="59dp"
android:layout_height="63dp"
android:id="@+id/imageButton2"
android:layout_gravity="bottom"
android:background="@drawable/positionbuttonup"
android:layout_marginBottom="1dp"
android:layout_marginLeft="1dp"
android:clickable="false" />
<ImageButton
android:layout_width="59dp"
android:layout_height="63dp"
android:id="@+id/imageButton3"
android:layout_gravity="bottom"
android:background="@drawable/envirobuttonup"
android:layout_marginBottom="1dp"
android:layout_marginLeft="1dp" />
</LinearLayout>
</LinearLayout>
对于.Java:
package com.example.savag.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
@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.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:2)
布局充气器似乎有些问题。
答案 1 :(得分:2)
您必须将您的xml文件显示为100%获得解决方案。当您将TOO大图像加载到屏幕时,大多数情况都会发生这种情况。尽量不要加载数据,这个问题可能会消失。
答案 2 :(得分:1)
我认为,你的Android应用程序背景图片很大。请转到AndroidManifest.xml并在AndroidManifest.xml文件中添加此行代码:
android:largeHeap="true"