Android: Out of memory on a 150994960-byte allocation
<p>If I use a genymotion emulator it works well, but if i'm testing it on my phone it won't respond.
I realy don't know why, but if I do set ContentView. I get the following error:</p>

<blockquote>
  <p>03-18 12:09:39.291 17403-17403/com.a42.tell I/dalvikvm-heap: Grow heap
  (frag case) to 115.420MB for 7817488-byte allocation 03-18
  12:09:47.416 17403-17403/com.a42.tell I/dalvikvm-heap: Forcing
  collection of SoftReferences for 150994960-byte allocation 03-18
  12:09:47.436 17403-17403/com.a42.tell E/dalvikvm-heap: Out of memory
  on a 150994960-byte allocation.</p>
</blockquote>

<p>can somebody tell me where the problem is or where i need to look to fix this error!</p>

<pre><code>public class FriendsActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private RecyclerView.Adapter mAdapter;
    private RecyclerView.LayoutManager mLayoutManager;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //System.gc();
        setContentView(R.layout.activity_friends); // It breaks here 
    ...
    }
}
</code></pre>

<p>
</p>

<pre><code>&lt;android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"&gt;

    &lt;android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" &gt;

        &lt;TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_activity_contacts"
            android:textSize="40dp"
            android:layout_gravity="center"
            android:id="@+id/toolbar_title" /&gt;


    &lt;/android.support.v7.widget.Toolbar&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;

&lt;android.support.v7.widget.RecyclerView
    android:id="@+id/rvContacts"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?attr/actionBarSize"/&gt;
</code></pre>

<p></p>

<p>UPDATE1: This is the adapter</p>

<pre><code>public class FriendsAdapter extends RecyclerView.Adapter&lt;FriendsAdapter.ViewHolder&gt; {
    private RealmResults&lt;UserRealm&gt; mDataset;
    // Provide a reference to the views for each data item
    // Complex data items may need more than one view per item, and
    // you provide access to all the views for a data item in a view holder
    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case
        public TextView tv_name;
        public long idto; //TODO: Do i still need this ?
        public ImageView micBtn;


        public ViewHolder(View v) {
            super(v);
            tv_name = (TextView) v.findViewById(R.id.tv_name);
            micBtn = (ImageView) v.findViewById(R.id.mic);




        }
    }

    // Provide a suitable constructor (depends on the kind of dataset)
    public FriendsAdapter(RealmResults&lt;UserRealm&gt; myDataset) {
        mDataset = myDataset;
    }

    // Create new views (invoked by the layout manager)
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent,
                                         int viewType) {
        // create a new view
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.friends_item, parent, false);
        // set the view's size, margins, paddings and layout parameters

        ViewHolder vh = new ViewHolder(v);

        vh.micBtn.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_CANCEL){Log.d("tagger", "ACTION_CANCEL"); return true;}

                if(event.getAction() == MotionEvent.ACTION_DOWN){Log.d("tagger", "ACTION_DOWN"); return true;}

                if(event.getAction() == MotionEvent.ACTION_MOVE){Log.d("tagger", "ACTION_MOVE"); return true;}

                if(event.getAction() == MotionEvent.ACTION_UP){Log.d("tagger", "ACTION_UP"); return true;}
                return false;
            }
        });




        return vh;
    }


    // Replace the contents of a view (invoked by the layout manager)
    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        holder.tv_name.setText(mDataset.get(position).getFullname());
                      holder.idto = 1;



    }

    // Return the size of your dataset (invoked by the layout manager)
    @Override
    public int getItemCount() {
        return mDataset.size();
    }
}
</code></pre>

<p>Update2: the entire stack trace</p>

<blockquote>
  <p>03-18 13:36:09.450 27910-27910/com.a42.jutella I/dalvikvm: Could not
  find method android.app.Notification$Builder.setLocalOnly, referenced
  from method com.google.android.gms.common.GooglePlayServicesUtil.zza
  03-18 13:36:09.450 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable
  to resolve virtual method 222:
  Landroid/app/Notification$Builder;.setLocalOnly
  (Z)Landroid/app/Notification$Builder; 03-18 13:36:09.455
  27910-27910/com.a42.jutella I/dalvikvm: Could not find method
  android.content.pm.PackageManager.getPackageInstaller, referenced from
  method com.google.android.gms.common.GooglePlayServicesUtil.zzh 03-18
  13:36:09.455 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to
  resolve virtual method 499:
  Landroid/content/pm/PackageManager;.getPackageInstaller
  ()Landroid/content/pm/PackageInstaller; 03-18 13:36:09.490
  27910-27935/com.a42.jutella I/GMPM: App measurement is starting up
  03-18 13:36:09.535 27910-27910/com.a42.jutella I/dalvikvm: Could not
  find method android.content.res.TypedArray.getChangingConfigurations,
  referenced from method
  android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
  03-18 13:36:09.535 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable
  to resolve virtual method 575:
  Landroid/content/res/TypedArray;.getChangingConfigurations ()I 03-18
  13:36:09.535 27910-27910/com.a42.jutella I/dalvikvm: Could not find
  method android.content.res.TypedArray.getType, referenced from method
  android.support.v7.internal.widget.TintTypedArray.getType 03-18
  13:36:09.535 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to
  resolve virtual method 597: Landroid/content/res/TypedArray;.getType
  (I)I 03-18 13:36:09.755 27910-27910/com.a42.jutella I/dalvikvm-heap:
  Grow heap (frag case) to 105.720MB for 81432016-byte allocation 03-18
  13:36:10.120 27910-27957/com.a42.jutella I/tagger: GCM Registration
  Token:
  eBVKL3ktgP8:APA91bFhgmYCHFaE3Vg7lVmnGusIsQd3XSOQeSV8XFgVY9pVHm_6CIHf5MCbX4DG3o65epGMFvAmeHhAIOuYD8UK170VSPj17ECmLyBfcF-3RnnIeEO2NRzKrlDneeJeYfOr6gV69g-J
  03-18 13:36:11.985 27910-27910/com.a42.jutella I/dalvikvm: Could not
  find method android.content.res.Resources.getDrawable, referenced from
  method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
  03-18 13:36:11.985 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable
  to resolve virtual method 538:
  Landroid/content/res/Resources;.getDrawable
  (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
  03-18 13:36:11.985 27910-27910/com.a42.jutella I/dalvikvm: Could not
  find method android.content.res.Resources.getDrawableForDensity,
  referenced from method
  android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
  03-18 13:36:11.985 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable
  to resolve virtual method 540:
  Landroid/content/res/Resources;.getDrawableForDensity
  (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
  03-18 13:36:14.390 27910-27910/com.a42.jutella I/dalvikvm-heap: Grow
  heap (frag case) to 115.151MB for 7817488-byte allocation 03-18
  13:36:14.410 27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$4; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.410
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$4;' failed 03-18 13:36:14.410
  27910-27910/com.a42.jutella E/dalvikvm: Could not find class
  'io.realm.rx.RealmObservableFactory$4', referenced from method
  io.realm.rx.RealmObservableFactory.getObjectObservable 03-18
  13:36:14.410 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to
  resolve new-instance 4347 (Lio/realm/rx/RealmObservableFactory$4;) in
  Lio/realm/rx/RealmObservableFactory; 03-18 13:36:14.410
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$3; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.410
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$3;' failed 03-18 13:36:14.410
  27910-27910/com.a42.jutella E/dalvikvm: Could not find class
  'io.realm.rx.RealmObservableFactory$3', referenced from method
  io.realm.rx.RealmObservableFactory.getRealmResultsObservable 03-18
  13:36:14.410 27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to
  resolve new-instance 4344 (Lio/realm/rx/RealmObservableFactory$3;) in
  Lio/realm/rx/RealmObservableFactory; 03-18 13:36:14.410
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$2; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.410
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$2;' failed 03-18 13:36:14.410
  27910-27910/com.a42.jutella E/dalvikvm: Could not find class
  'io.realm.rx.RealmObservableFactory$2', referenced from method
  io.realm.rx.RealmObservableFactory.from 03-18 13:36:14.410
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to resolve
  new-instance 4341 (Lio/realm/rx/RealmObservableFactory$2;) in
  Lio/realm/rx/RealmObservableFactory; 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$1; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$1;' failed 03-18 13:36:14.415
  27910-27910/com.a42.jutella E/dalvikvm: Could not find class
  'io.realm.rx.RealmObservableFactory$1', referenced from method
  io.realm.rx.RealmObservableFactory.from 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to resolve
  new-instance 4338 (Lio/realm/rx/RealmObservableFactory$1;) in
  Lio/realm/rx/RealmObservableFactory; 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: VFY: unable to find class
  referenced in signature (Lrx/Observable;) 03-18 13:36:14.415
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$4; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$4;' failed 03-18 13:36:14.415
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$3; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$3;' failed 03-18 13:36:14.415
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$2; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$2;' failed 03-18 13:36:14.415
  27910-27910/com.a42.jutella I/dalvikvm: Failed resolving
  Lio/realm/rx/RealmObservableFactory$1; interface 4910
  'Lrx/Observable$OnSubscribe;' 03-18 13:36:14.415
  27910-27910/com.a42.jutella W/dalvikvm: Link of class
  'Lio/realm/rx/RealmObservableFactory$1;' failed 03-18 13:36:16.035
  27910-27910/com.a42.jutella I/dalvikvm-heap: Forcing collection of
  SoftReferences for 150994960-byte allocation 03-18 13:36:16.055
  27910-27910/com.a42.jutella E/dalvikvm-heap: Out of memory on a
  150994960-byte allocation. 03-18 13:36:16.055
  27910-27910/com.a42.jutella I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:   |
  group="main" sCount=0 dsCount=0 obj=0x417bed50 self=0x417ad668 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:   | sysTid=27910
  nice=0 sched=0/0 cgrp=apps handle=1074200916 03-18 13:36:16.055
  27910-27910/com.a42.jutella I/dalvikvm:   | state=R schedstat=(
  2243809464 48789052 1220 ) utm=165 stm=58 core=5 03-18 13:36:16.055
  27910-27910/com.a42.jutella I/dalvikvm:     at
  android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:606)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:433)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.content.res.Resources.loadDrawable(Resources.java:2168) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  com.huawei.android.content.res.ResourcesEx.loadDrawable(ResourcesEx.java:649)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.content.res.TypedArray.getDrawable(TypedArray.java:650) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.View.(View.java:3562) 03-18 13:36:16.055
  27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.ViewGroup.(ViewGroup.java:470) 03-18 13:36:16.055
  27910-27910/com.a42.jutella I/dalvikvm:     at
  android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:166)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:162)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  java.lang.reflect.Constructor.constructNative(Native Method) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  java.lang.reflect.Constructor.newInstance(Constructor.java:423) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.LayoutInflater.createView(LayoutInflater.java:614) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
  03-18 13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:489) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:409) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.view.LayoutInflater.inflate(LayoutInflater.java:358) 03-18
  13:36:16.055 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  com.a42.jutella.FriendsActivity.onCreate(FriendsActivity.java:27)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.Activity.performCreate(Activity.java:5285) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2345)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.ActivityThread.access$1100(ActivityThread.java:139) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.os.Handler.dispatchMessage(Handler.java:102) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  android.os.Looper.loop(Looper.java:136) 03-18 13:36:16.060
  27910-27910/com.a42.jutella I/dalvikvm:     at
  android.app.ActivityThread.main(ActivityThread.java:5314) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  java.lang.reflect.Method.invokeNative(Native Method) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  java.lang.reflect.Method.invoke(Method.java:515) 03-18 13:36:16.060
  27910-27910/com.a42.jutella I/dalvikvm:     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
  03-18 13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:678) 03-18
  13:36:16.060 27910-27910/com.a42.jutella I/dalvikvm:     at
  dalvik.system.NativeStart.main(Native Method) 03-18 13:36:16.065
  27910-27910/com.a42.jutella W/dalvikvm: threadid=1: thread exiting
  with uncaught exception (group=0x417bdc50)</p>
</blockquote>