1

I am trying to add separate portrait-landscape layouts to an older project of mine (basically I display 2 Fragments: one with a google-map and the other one contains some OpenGL drawings). I created a layout resource folder named layout-land that includes my landscape layout and I get an error in Android Studio:

Error:Execution failed for task ':MapDemoActivity:mergeDebugResources'.
> java.lang.NullPointerException (no error message)

in my Gradle Console:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MapDemoActivity:mergeDebugResources'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option
to get more log output.

I am a beginner and I don't know how to Run with --stacktrace option to get the stack trace or anything similar.

here's my portrait layout (activity_main.XML) that works fine when I don't have the layout-land folder:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:animateLayoutChanges="true"
>

<fragment
    android:id="@+id/map"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="350dp"
    android:layout_alignParentBottom="true"/>
<fragment
    android:id="@+id/openGL"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    class="com.example.mapdemo.OpenGLES20ActivityFrag"
    android:layout_above="@id/map"/>

</RelativeLayout>

the layout with the same name in my layout-land folder (when I add this folder I get the above-mentioned error, I tried with a simple HelloWorld-style layout and it still didn't work so I don't think it has anything to do with what it contains):

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:baselineAligned="false"
android:orientation="horizontal"
tools:context=".MainActivity">

<fragment
    android:id="@+id/map"
    android:layout_width="400dp"
    android:layout_height="match_parent"

    class="com.google.android.gms.maps.SupportMapFragment" />

<fragment
    android:id="@+id/openGL"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    class="com.example.mapdemo.OpenGLES20ActivityFrag" />

</LinearLayout>

If aditional code is required I will post it, however I don't think it is necesary. I do have the latest SDK and IDE versions.

I think if could just find out where the NullPointerException error is in my code, I could solve it, but I don't know how to find it

ChrisX
  • 334
  • 1
  • 5
  • 20
  • maybe it is because You named Your parent layouts different...+id/RelativeLayout1 & @+id/LinearLayout1. Are you refer this layouts anywhere? – Opiatefuchs Jul 24 '14 at 12:08
  • well I deleted the ids and still the same thing happens. I didn't use them anywhere – ChrisX Jul 24 '14 at 12:10

1 Answers1

3

Note sure if this answer is still required. But I ran into this exact issue and searching more on StackOverflow I found the answer in this post Android Studio - mergeDebugResources exception

"It happens to me only when modifying the XML files on the project. If you rebuild the entire project before running (Build > Rebuild Project) it doesn't show up anymore."

I rebuilt my project following and this issue went away and i can run my app and my different portrait and landscape layouts are used.

Community
  • 1
  • 1
se22as
  • 2,282
  • 5
  • 32
  • 54