Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException #174

Closed
mhrlive opened this issue Feb 19, 2020 · 6 comments
Closed

IllegalArgumentException #174

mhrlive opened this issue Feb 19, 2020 · 6 comments
Labels
Bug report Participants report a bug Bug bug!!

Comments

@mhrlive
Copy link

mhrlive commented Feb 19, 2020

Im getting lot of crashes from my users
Android 8 and 9
I still cant reproduce the behavior
any help or fix

Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:1042) at android.graphics.Bitmap.createBitmap(Bitmap.java:1009) at android.graphics.Bitmap.createBitmap(Bitmap.java:959) at android.graphics.Bitmap.createBitmap(Bitmap.java:920) at com.github.anastr.speedviewlib.LinearGauge.createForegroundBitmapCanvas(LinearGauge.java:23) at com.github.anastr.speedviewlib.ProgressiveGauge.updateFrontAndBackBitmaps(ProgressiveGauge.java:2) at com.github.anastr.speedviewlib.LinearGauge.updateBackgroundBitmap(LinearGauge.java) at com.github.anastr.speedviewlib.LinearGauge.onSizeChanged(LinearGauge.java:3) at android.view.View.sizeChange(View.java:21272) at android.view.View.setFrame(View.java:21233) at android.view.View.layout(View.java:21085) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1801) at android.widget.LinearLayout.onLayout(LinearLayout.java:1567) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.widget.ScrollView.onLayout(ScrollView.java:1622) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at androidx.viewpager.widget.ViewPager.onLayout(ViewPager.java:259) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:3) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:1320) at android.view.View.layout(View.java:21090) at android.view.ViewGroup.layout(ViewGroup.java:6460) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2994) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2505) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1575) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7636) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1029) at android.view.Choreographer.doCallbacks(Choreographer.java:834) at android.view.Choreographer.doFrame(Choreographer.java:763) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1015) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7070) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)

My XML:
<com.github.anastr.speedviewlib.AwesomeSpeedometer android:id="@+id/datagaugespeed" android:layout_width="200dp" android:layout_height="0dp" android:layout_weight="1" android:layout_gravity="center" android:layout_marginTop="5dp" android:padding="8dp" app:sv_maxSpeed="100" app:sv_speedometerColor="@color/blueetooth_color" app:sv_unit="MB/s" app:sv_trembleDegree="2" app:sv_trembleDuration="6000" app:sv_unitTextColor="@color/yellow" />

@mhrlive mhrlive added the Bug report Participants report a bug label Feb 19, 2020
@anastr
Copy link
Owner

anastr commented Feb 19, 2020

Please make sure that the final height is not 0.
I can't ensure the height of your speedometer cause of layout_weight=1, if you can send the full layout to check it out.

@mhrlive
Copy link
Author

mhrlive commented Feb 20, 2020

Thanks !

`

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:animateLayoutChanges="true"
    android:orientation="vertical" 
    android:overScrollMode="always"
    android:paddingBottom="15dp"
    android:scrollbars="vertical">

    <androidx.cardview.widget.CardView
        android:id="@+id/contentcard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/titlecard"
        android:layout_margin="5dp"
        app:cardUseCompatPadding="true">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TableLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    tools:ignore="UselessParent"
                    android:padding="10dp"
                    android:paddingBottom="0dp">


                    <TableRow android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Mobile Data Speed"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_speed"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            app:textAllCaps="true"/>
                    </TableRow>

                    <TableRow android:gravity="start"
                        android:layout_marginTop="8dp">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Mobile Data type"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_networkname"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            app:textAllCaps="true"/>
                    </TableRow>

                    <TableRow android:gravity="start"
                        android:layout_marginTop="8dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Local IP"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_ip"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            app:textAllCaps="true"/>
                    </TableRow>

                    <TableRow android:gravity="start"
                        android:layout_marginTop="10dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="DNS1"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_dns1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            app:textAllCaps="true"/>
                    </TableRow>

                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="DNS2"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_dns2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            tools:ignore="MissingPrefix"
                            android:textStyle="bold"
                            tools:targetApi="jelly_bean" />
                    </TableRow>


                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="IP V6"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_ipv6"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            android:text = ""/>
                    </TableRow>


                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="This Device MAC"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_devicemac"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textIsSelectable="true"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean"
                            android:textAllCaps="true" />
                    </TableRow>


                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Lease address"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_lease"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:textIsSelectable="true"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean" />
                    </TableRow>

                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Server IP"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_serverip"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:textIsSelectable="true"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean" />
                    </TableRow>

                    <TableRow
                        android:layout_marginTop="10dp"
                        android:gravity="start">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="5"
                            android:maxLines="4"
                            android:text="Subnet Mask"
                            android:textColor="@color/secondary_text"
                            android:textSize="14sp"
                            tools:targetApi="jelly_bean" />

                        <TextView
                            android:id="@+id/tv_mask"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:textIsSelectable="true"
                            android:ellipsize="end"
                            android:fontFamily="@font/lato_regular"
                            android:gravity="start"
                            android:maxEms="4"
                            android:maxLines="4"
                            android:textColor="@color/primary_text"
                            android:textSize="14sp"
                            android:textStyle="bold"
                            tools:ignore="MissingPrefix"
                            tools:targetApi="jelly_bean" />
                    </TableRow>

            </LinearLayout>
        </ScrollView>
    </androidx.cardview.widget.CardView>


    <androidx.cardview.widget.CardView
        android:id="@+id/gaugecard"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/contentcard"
        android:layout_centerInParent="true"
        android:layout_margin="4dp"
        app:cardUseCompatPadding="true">

        <LinearLayout
            android:id="@+id/linearlay2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal">

            <FrameLayout
                android:id="@+id/signalframe"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="5dp"
                    android:text="Mobile Network Speed"
                    android:textStyle="bold"
                    android:paddingStart="5dp"/>

                <com.github.anastr.speedviewlib.AwesomeSpeedometer
                    android:id="@+id/datagaugespeed"
                    android:layout_width="200dp"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:layout_gravity="center"
                    android:layout_marginTop="5dp"
                    android:padding="8dp"
                    app:sv_maxSpeed="100"
                    app:sv_speedometerColor="@color/blueetooth_color"
                    app:sv_unit="MB/s"
                    app:sv_trembleDegree="2"
                    app:sv_trembleDuration="6000"
                    app:sv_unitTextColor="@color/yellow" />

            </FrameLayout>

        </LinearLayout>

    </androidx.cardview.widget.CardView>



    <Button
        android:id="@+id/telnet"
        style="@style/Widget.AppCompat.Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/gaugecard"
        android:layout_centerHorizontal="true"
        android:text="Telnet Reboot"
        android:layout_marginBottom="5dp"/>

</RelativeLayout>

`

should I remove the layout_weight ?

@anastr
Copy link
Owner

anastr commented Feb 20, 2020

nope, leave everything as it is for now.
new version is coming in the next couple days, and it should ignore view size if it is 0...

@anastr anastr added the Bug bug!! label Feb 20, 2020
@mhrlive
Copy link
Author

mhrlive commented Feb 20, 2020

Thanks, I"m waiting for it to update my App :)

@anastr
Copy link
Owner

anastr commented Feb 20, 2020

just quick solution for your layout.
these 2 lines:

  android:layout_height="0dp"
  android:layout_weight="1"

are invalid since AwesomeSpeedometer is a child of FrameLayout cause layout_weight only available for LinearLayout children, for this your speedometer view is forced to get 0 height, and that 'logically' isn't sense.

whatever changes are going to be in the next new version it may solve the exception, but your speedometer height still 0! and it will not be visible.
try to add fixed height or make change in your layout to make it right.

have a good day ❤️ .

@anastr
Copy link
Owner

anastr commented Feb 23, 2020

fixed, new version c93b5e1.

@anastr anastr closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug report Participants report a bug Bug bug!!
Projects
None yet
Development

No branches or pull requests

2 participants