Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Displaying image - Surface is not valid

Tags:

java

android

06-30 11:59:40.153  27202-27202/com.downloader.newlevel.krim.newleveldownloader E/ViewSystem﹕ ViewRootImpl #2 Surface is not valid.
06-30 11:59:41.114  27202-27216/com.downloader.newlevel.krim.newleveldownloader E/Error﹕ https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2
06-30 12:00:57.429  27202-27202/com.downloader.newlevel.krim.newleveldownloader E/ViewSystem﹕ ViewRootImpl #2 Surface is not valid.
06-30 12:00:58.219  27202-27755/com.downloader.newlevel.krim.newleveldownloader E/Error﹕ https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2

This was found in my logcat, I am currently working on loading image from url.

Activity

        package com.downloader.newlevel.krim.newleveldownloader;

        import android.content.Intent;
        import android.graphics.Bitmap;
        import android.graphics.BitmapFactory;
        import android.os.AsyncTask;
        import android.os.Bundle;
        import android.support.v7.app.ActionBarActivity;
        import android.util.Log;
        import android.view.Menu;
        import android.view.MenuItem;
        import android.widget.ImageView;

        import java.io.InputStream;


        public class activity00 extends ActionBarActivity {

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity00);
                String url000 = "https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2";
                new DownloadImageTask((ImageView) findViewById(R.id.image_main00)).execute(url000);
    Intent splash = new Intent(this, splash_activity.class);
    startActivity(splash);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.settings, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_search) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

AsyncTask downloading image

class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    }
 }

Layout

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollView"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:cardview="http://schemas.android.com/apk/res-auto"
    tools:context=".activity00"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:orientation="horizontal">

        <TableLayout
            android:id="@+id/tableLayout_main00"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:stretchColumns="*">
            <TableRow>
                <Button
                    android:text="Script"
                    android:textAllCaps="false"
                    android:background="#ffffff"/>
                <Button
                    android:text="Add-on"
                    android:textAllCaps="false"
                    android:background="#fffffa6a"/>
            </TableRow> <TableRow>
            <Button
                android:text="Map"
                android:textAllCaps="false"
                android:background="#ff6ec0ff"/>
            <Button
                android:text="Skin"
                android:textAllCaps="false"
                android:background="#ffff6d66"/>
        </TableRow> <TableRow>
            <Button
                android:text="Texture Pack"
                android:textAllCaps="false"/>
            <Button
                android:text="Coming Soon"
                android:textAllCaps="false"/>
        </TableRow>
        </TableLayout>

        <TextView
            android:id="@+id/text_main00"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="New"
            android:textSize="20sp"
            android:layout_below="@+id/tableLayout_main00"
            android:clickable="true"
            android:gravity="right"
            android:layout_marginTop="20dp"/>

        <android.support.v7.widget.CardView
            android:id="@+id/cardview_main00"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            cardview:cardCornerRadius="4dp"
            android:layout_below="@+id/text_main00"
            android:clickable="true"
            android:layout_marginTop="5dp">

            <ImageView
                android:id="@+id/image_main00"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:scaleType="fitStart"/>

            <TextView
                android:id="@+id/text_main_cardview00"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hourglass Addon by Redstone"
                android:layout_gravity="bottom"/>

        </android.support.v7.widget.CardView>

        <TextView
            android:id="@+id/text_main01"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Popular"
            android:textSize="20sp"
            android:layout_below="@+id/cardview_main00"
            android:clickable="true"
            android:gravity="right"
            android:layout_marginTop="10dp"/>

        <android.support.v7.widget.CardView
            android:layout_below="@+id/text_main01"
            android:id="@+id/cardview_main01"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            cardview:cardCornerRadius="4dp"
            android:clickable="true"
            android:layout_marginTop="5dp">

            <ImageView
                android:id="@+id/image_main01"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:scaleType="fitStart"/>

            <TextView
                android:id="@+id/text_main_cardview01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Armor Display by Chan"
                android:layout_gravity="bottom"/>

        </android.support.v7.widget.CardView>

        <TextView
            android:id="@+id/text_main02"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Coming Soon"
            android:textSize="20sp"
            android:layout_below="@+id/cardview_main01"
            android:clickable="true"
            android:gravity="right"
            android:layout_marginTop="10dp"/>

        <android.support.v7.widget.CardView
            android:layout_below="@+id/text_main02"
            android:id="@+id/cardview_main02"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            cardview:cardCornerRadius="4dp"
            android:clickable="true"
            android:layout_marginTop="5dp">

            <ImageView
                android:id="@+id/image_main02"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:scaleType="fitStart"/>

            <TextView
                android:id="@+id/text_main_cardview02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="PortalPX by TM"
                android:layout_above="@+id/text_main_cardview22"/>

            <TextView
                android:id="@+id/text_main_cardview22"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Limited Edition: Cabon Version"
                android:layout_gravity="bottom"/>


        </android.support.v7.widget.CardView>


    </RelativeLayout>

</ScrollView>

I don't know why this logcat appeared. Can anyone explain and solve it please?

like image 772
Krim Avatar asked Mar 16 '23 13:03

Krim


1 Answers

"ViewRootImpl #2 Surface is not valid." in logcat means something went wrong in layout. I fixed mine by writing whole layout again...to make sure everything is okay :) Splash screen had nothing to do with this error

like image 172
Krim Avatar answered Mar 18 '23 03:03

Krim