So, heres the point:
I'm training up and making my first steps in android development and after I narrowed down a few errors myself, I finally came across one that I cant find the solution for.
I want to create an app that displays two pictures that split the screen in half horizontally. So I create a LinearLayout
with a vertical orientation and add two RelativeLayout
's inside it. I compile it and the build apparently completes but as soon as the app tries to start up on my mobile (Samsung S5 Neo) it says it stopped working and I land up on my desktop again. >.< Also, before tips alike arise - yes I started a new project for testing purposes already and the same error occurs. Also, when I remove that lines of code, the app works just fine on my mobile. So, that's my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="removedbecausenotyourbusiness:P">
<RelativeLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent">
<ImageView
android:id="@+id/background2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background2"
android:scaleType="centerCrop"/>
</RelativeLayout>
<RelativeLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent">
<ImageView
android:id="@+id/background1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background1"
android:scaleType="centerCrop"/>
</RelativeLayout>
</LinearLayout>
Also, I'd like to get to know if I can somehow get a log from my mobile as to WHY the app stopped working. Where can I get this?
EDIT: I believe I found what you were asking me for.
12-17 19:27:18.751 11830-11830/? E/Zygote: v2 12-17 19:27:18.751 11830-11830/? E/Zygote: accessInfo : 0 12-17 19:27:20.211 11830-11830/com.example.marco E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.marco, PID: 11830 java.lang.OutOfMemoryError: Failed to allocate a 231444012 byte allocation with 4182352 free bytes and 125MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:2228) at android.content.res.Resources.loadDrawableForCookie(Resources.java:4211) at android.content.res.Resources.loadDrawable(Resources.java:4085) at android.content.res.Resources.loadDrawable(Resources.java:3935) at android.content.res.TypedArray.getDrawable(TypedArray.java:886) at android.widget.ImageView.(ImageView.java:157) at android.widget.ImageView.(ImageView.java:145) at android.support.v7.widget.AppCompatImageView.(AppCompatImageView.java:60) at android.support.v7.widget.AppCompatImageView.(AppCompatImageView.java:56) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1021) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080) at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.inflate(LayoutInflater.java:527) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.example.marco.MainActivity.onCreate(MainActivity.java:11) at android.app.Activity.performCreate(Activity.java:6877) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3208) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3351) at android.app.ActivityThread.access$1100(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7230) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)