无法分配大小

时间:2017-01-09 14:14:16

标签: java android memory out-of-memory

我遇到这个问题,打开后应用程序崩溃了。

错误日志:

FATAL EXCEPTION: main
Process: com.sp.ez_mart, PID: 30921
java.lang.OutOfMemoryError: Failed to allocate a 416160012 byte allocation with 11861984 free bytes and 239MB until OOM
  at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:855)
  at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:706)
  at android.content.res.Resources.getDrawable(Resources.java:776)
  at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:133)
  at android.content.Context.getDrawable(Context.java:525)
  at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
  at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202)
  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:192)
  at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:49)
  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:65)
  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:53)
  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
  at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
  at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
  at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
  at com.sp.ez_mart.Store_Layout.onCreate(Store_Layout.java:15)
  at android.app.Activity.performCreate(Activity.java:6754)

Java代码:

public class Store_Layout extends AppCompatActivity {

  ImageView imageView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_store_layout);

    imageView = (ImageView)findViewById(R.id.imageView);
    PhotoViewAttacher photoView = new PhotoViewAttacher(imageView);
    photoView.update();
  }
}

0 个答案:

没有答案