0

I have this problem with our app. It works great in Android 4.1 version but not in 4.3. I´m running 4.1 in Samsung S2 and 4.3 in Samsung S4. Problems are apparently in main.xml. There are visibility:gone buttons that causes errors my opinion. If I just remove those buttons and their functions, app starts normally.

I have only one layout file at the moment. layout-large and other folders are removed. Android manifest file looks ok also.

I´m just wondering is this normal that apps work different in different android versions?

Here´s the code for main.xml. Do you find any errors in it or should I do something different?

EDIT: Problems were in png files. App errored systemoutmemory. There are only about 13 small (35kb) files in mainactivity. I solved the problem adding android:largeHeap="true" to manifest file. Really strange problems because everything worked great in 4.0 4.1 4.2 and 4.4 versions.

### Layout XML ###

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"  >

    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="1"
    android:orientation="vertical" >

        <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:contentDescription="@string/fuel_image"
        android:adjustViewBounds="true"
        android:layout_marginRight="20sp"
        android:layout_marginLeft="20sp"
        android:layout_marginTop="20sp"
        android:src="@drawable/logo"/>

        <Button
        android:id="@+id/btnMagnify"
        android:layout_width="210sp"
        android:layout_height="215sp"
        android:layout_gravity="center"
        android:layout_marginTop="10sp"
        android:adjustViewBounds="true"
        android:background="@drawable/magnify_button"  />

        <Button
        android:id="@+id/btnConnecting"
        android:visibility="gone"               
        android:layout_width="210sp"
        android:layout_height="215sp"
        android:layout_gravity="center"
        android:layout_marginTop="10sp"
        android:adjustViewBounds="true"
        android:background="@drawable/button_connecting"  />

        <Button
        android:id="@+id/btnKalibroi"
        android:visibility="gone" 
        android:layout_width="210sp"
        android:layout_height="215sp"
        android:layout_gravity="center"
        android:layout_marginTop="10sp"
        android:adjustViewBounds="true"
        android:background="@drawable/calibrate_button"  />

        <Button
        android:id="@+id/btnSensor"
        android:visibility="gone" 
        android:layout_width="210sp"
        android:layout_height="215sp"
        android:layout_gravity="center"
        android:layout_marginTop="10sp"
        android:adjustViewBounds="true"
        android:background="@drawable/button_flex"  />

        <Button
        android:id="@+id/btnCold"
        android:visibility="gone" 
        android:layout_width="210sp"
        android:layout_height="215sp"
        android:layout_gravity="center"
        android:layout_marginTop="10sp"
        android:adjustViewBounds="true"
        android:background="@drawable/button_cold"  />

        <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:visibility="gone" 
        android:layout_marginTop="5sp"
        android:layout_gravity="center" >
        </ProgressBar>

        <TextView
        android:id="@+id/txtfuel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textColor="#ffffff"
        android:layout_marginTop="5sp"
        android:layout_marginRight="20sp"
        android:layout_marginLeft="20sp"
        android:layout_gravity="center"
        android:textSize="14sp" />

        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

            <Button
            android:id="@+id/btnCalc"
            android:layout_width="55sp"
            android:layout_height="60sp"
            android:layout_gravity="left"
            android:layout_marginLeft="10sp"
            android:adjustViewBounds="true"
            android:layout_alignParentLeft="true"
            android:background="@drawable/calc_button"  />

            <Button
            android:id="@+id/btnGauge"
            android:layout_width="60sp"
            android:layout_height="60sp"
            android:layout_gravity="right"
            android:layout_marginRight="10sp"
            android:adjustViewBounds="true"
            android:layout_alignParentRight="true"
            android:background="@drawable/gauge_button"  />

        </RelativeLayout>

    </LinearLayout>

</ScrollView>
tshepang
  • 12,111
  • 21
  • 91
  • 136
RareBoy
  • 77
  • 2
  • 13
  • Are you using an emulator.. ADT eclipse ? – JayD Mar 12 '14 at 15:53
  • What's your logcat say? – 323go Mar 12 '14 at 15:53
  • I´m not using emulators. Using phones because it's a bluetooth app. – RareBoy Mar 12 '14 at 15:56
  • Error in logcat is dalvikvm-heap, Out of memory on a 5760016-byte allocation, 4473 – RareBoy Mar 12 '14 at 15:58
  • That seems like a weird error to get from having a few buttons in your layout... It likely has to do with Android being unhappy about having to draw all of those bitmaps from resource. – zgc7009 Mar 12 '14 at 16:02
  • Check out http://stackoverflow.com/questions/1147172/what-android-tools-and-methods-work-best-to-find-memory-resource-leaks and the answer with 55 upvotes (not the selected one). The reason it might work on 4.1 but not 4.3 is that garbage collection algorithms might have been tweaked differently or something in 4.3. Not really sure – zgc7009 Mar 12 '14 at 16:04
  • App works 4.0 4.1 4.2 and 4.4 versions. It only have 13 small 35kb png files. Still working on this. – RareBoy Mar 13 '14 at 14:08
  • I checked all kind of BitmapFactory.Options stuff but got nothing to work. Than I just added to AndroidManifest.xml this line to mainactivity android:largeHeap="true". Now app works great. – RareBoy Mar 13 '14 at 15:51

0 Answers0