I have the following error: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method

0

The error: 07-04 20: 53: 57.200 2133-2133 / lexdroixbdejemplorufus.bdejemplo E / dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android .support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

I do not know why it fails, the error says the class is not found rippleDrawable but I compile the project and the graphical interface looks good in the emulator but the search does not work in the sqlite database

public class DataBaseHelper extends SQLiteOpenHelper {

    private static String DB_PATH = "data/data/lexdroixbdejemplorufus.bdejemplo/databases/";
    static final String DB_NAME ="bdejemplo.sqlite";
    private SQLiteDatabase myDataBase;
    public  Context myContext;


    public DataBaseHelper(Context context)
    {
        super(context,DB_NAME,null,1);
        this.myContext = context;

    }

    public void createDataBase() throws IOException
    {
        boolean dbExist = checkDataBase();
        SQLiteDatabase db_Read = null;

        if(dbExist)
        {

        }
        else
        {
            db_Read = this.getReadableDatabase();
            db_Read.close();

            try
            {
                copyDataBase();
            }
            catch (Exception e)
            {
                throw new Error("Error copying database");
            }

        }
    }

    public void copyDataBase() throws IOException
    {
        InputStream myInput = myContext.getAssets().open(DB_NAME);
        String outFileName = DB_PATH + DB_NAME;

        OutputStream myOutput= new FileOutputStream(outFileName);

        byte[] buffer = new byte[1024];
        int lenght;

        while((lenght = myInput.read(buffer)) != -1)
        {
            if(lenght > 0)
            {
                myOutput.write(buffer,0,lenght);
            }
        }

        myOutput.flush();
        myOutput.close();
        myInput.close();
    }

    public boolean checkDataBase()
    {
        SQLiteDatabase checkDB = null;
        String myPath = DB_PATH + DB_NAME;

        try
        {
            checkDB = SQLiteDatabase.openDatabase(myPath,null,SQLiteDatabase.OPEN_READWRITE);
        }
        catch(SQLException e)
        {
            File dbFile = new File(DB_PATH + DB_NAME);
            return dbFile.exists();
        }

        if(checkDB != null)
            checkDB.close();

        return checkDB != null ? true : false;

    }

    public void openDataBase() throws  SQLException
    {
        String myPath = DB_PATH + DB_NAME;
        myDataBase = SQLiteDatabase.openDatabase(myPath,null,SQLiteDatabase.OPEN_READONLY);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }

    public Cursor fetchTeacher(String palabra) throws SQLiteException
    {
        String[] campos = new String[]{"id", "nombre"};
        String[] args = new String[]{palabra};

        Cursor qCursor= myDataBase.query("maestros",campos,"nombre=?", args,null,null,null);
        if(qCursor != null)
            qCursor.moveToFirst();
        return qCursor;
    }
}




public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    TextView campo1,campo2;
    Button boton, boton2, boton3;
    EditText edit;
    String palabra;
    private DataBaseHelper myDbHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        edit = (EditText) findViewById(R.id.edit);
        boton = (Button) findViewById(R.id.boton);
        boton = (Button) findViewById(R.id.boton);
        boton2 = (Button) findViewById(R.id.boton2);
        boton3 = (Button) findViewById(R.id.boton3);
        campo1 = (TextView) findViewById(R.id.campo1);
        campo2 = (TextView) findViewById(R.id.campo2);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.boton:
                myDbHelper = new DataBaseHelper(this);
                palabra = edit.getText().toString();


                    try
                    {
                        myDbHelper.createDataBase();
                    } catch (IOException e)
                    {
                        throw new Error("no se puede crear");
                    }




                try
                {
                    myDbHelper.openDataBase();
                    Cursor cursor = myDbHelper.fetchTeacher(palabra);

                    if(cursor !=null)
                    {
                        campo1.setText(cursor.getString(0));
                        campo2.setText(cursor.getString(1));
                        cursor.close();
                        myDbHelper.close();
                    }
                }

                catch (SQLException e)
                {
                    e.printStackTrace();
                }
                break;
            case R.id.boton2:
                break;
            case R.id.boton3:
                break;
        }
    }
}

activity_main.xml

<?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:orientation="vertical"

    tools:context="lexdroixbdejemplorufus.bdejemplo.MainActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/edit"
        android:hint="dato" />

    <Button
        android:id="@+id/boton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="buscar"
        />

    <Button
        android:id="@+id/boton2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="insertar"
        />


    <Button
        android:id="@+id/boton3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="borrar"
        />

    <TextView

        android:id="@+id/campo1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        />

    <TextView

        android:id="@+id/campo2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        />
</LinearLayout>
    
asked by Rafael Hernández 05.07.2016 в 03:05
source

1 answer

1

In this case you will have to validate the use of class RippleDrawable , you can do it this way:

if(Build.VERSION.SDK_INT >=  Build.VERSION_CODES.LOLLIPOP){

 //uso de RippleDrawable.      

}
    
answered by 07.07.2016 в 13:25