Android错误getSlotFromBufferLocked:未知缓冲区:0xa9fb8d90

时间:2021-10-13 19:08:22

i am working on an android app which uses material-intro dependencies for intro slides, but when the slide complete and try to switch from the Slide(MaterialintroActivity) to my main activity the app crashes.

我正在开发一个Android应用程序,它使用介绍幻灯片的材质介绍依赖项,但当幻灯片完成并尝试从幻灯片(MaterialintroActivity)切换到我的主要活动时,应用程序崩溃。

LogCat

 07-26 12:42:19.566 897-944/com.naive.LISTY E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa9fb8d90

AppManifest code

<application
    android:allowBackup="true"
    android:icon="@mipmap/icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainIntroActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MainActivity"/>
</application>

MainIntroActivity

public class MainIntroActivity extends IntroActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {

    setFullscreen(true);
    super.onCreate(savedInstanceState);

    addSlide(new SimpleSlide.Builder()
            .title(R.string.title)
            .description(R.string.description)
            .image(R.mipmap.ic_launcher)
            .background(R.color.background)
            .backgroundDark(R.color.background_dark)
            .buttonCtaClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v)
                {
                    Intent main=new Intent(MainIntroActivity.this, MainActivity.class);
                    startActivity(main);
                }
            })
            .build());
}}

MainActivity code

public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";

private TaskDbHelper mHelper;
private ListView mTaskListView;
private ArrayAdapter<String> mAdapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

      if(!prefs.getBoolean("new1",false)){

        //Only 1st time run code here

        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean("new1", true);
        editor.commit();
     }*/

    setContentView(R.layout.activity_main);
    mHelper = new TaskDbHelper(this);
    mTaskListView = (ListView) findViewById(R.id.list_todo);
    updateUI();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    return super.onCreateOptionsMenu(menu);
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_add_task:

        final EditText taskEditText = new EditText(this);
        AlertDialog dialog = new AlertDialog.Builder(this)
                .setTitle("Add new task")
               // .setMessage("What do you want to do next?")
                .setView(taskEditText)
                .setPositiveButton("Add", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String task = String.valueOf(taskEditText.getText());
                        if(task != null && !task.isEmpty()) {
                            SQLiteDatabase db = mHelper.getWritableDatabase();
                            ContentValues values = new ContentValues();
                            values.put(TaskContract.TaskEntry.COL_TASK_TITLE, task);
                            db.insertWithOnConflict(TaskContract.TaskEntry.TABLE,
                                    null,
                                    values,
                                    SQLiteDatabase.CONFLICT_REPLACE);
                            updateUI();
                            db.close();
                        } else {

                        }
                    }
                })
                .setNegativeButton("Cancel", null)
                .create();
        dialog.show();

        default:
            return super.onOptionsItemSelected(item);
    }
}

private void updateUI() {
    ArrayList<String> taskList = new ArrayList<>();
    SQLiteDatabase db = mHelper.getReadableDatabase();
    Cursor cursor = db.query(TaskContract.TaskEntry.TABLE,
            new String[]{TaskContract.TaskEntry._ID, TaskContract.TaskEntry.COL_TASK_TITLE},
            null, null, null, null, null);
    while (cursor.moveToNext()) {
        int idx = cursor.getColumnIndex(TaskContract.TaskEntry.COL_TASK_TITLE);
        taskList.add(cursor.getString(idx));
    }

    if (mAdapter == null) {
        mAdapter = new ArrayAdapter<>(this,
                R.layout.item_todo,
                R.id.task_title,
                taskList);
        mTaskListView.setAdapter(mAdapter);
    } else {
        mAdapter.clear();
        mAdapter.addAll(taskList);
        mAdapter.notifyDataSetChanged();
    }

    cursor.close();
    db.close();
}

public void deleteTask(View view) {
    View parent = (View) view.getParent();
    TextView taskTextView = (TextView) parent.findViewById(R.id.task_title);
    String task = String.valueOf(taskTextView.getText());
    SQLiteDatabase db = mHelper.getWritableDatabase();
    db.delete(TaskContract.TaskEntry.TABLE,
            TaskContract.TaskEntry.COL_TASK_TITLE + " = ?",
            new String[]{task});
    db.close();
    updateUI();
}
}

5 个解决方案

#1


0  

Are you testing with marshmallow version ? cause i found that issue : https://code.google.com/p/android/issues/detail?id=192357

您是否使用棉花糖版本进行测试?因为我发现了这个问题:https://code.google.com/p/android/issues/detail?id = 192357

can u try to change oncreate function from :

你可以尝试改变oncreate函数:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.<YOUR_XML_FILE_NAME>);

To this :

对此:

@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onCreate(savedInstanceState, persistentState);
    setContentView(R.layout.<YOUR_XML_FILE_NAME>);
}

if the problem persist try to update your android version its an issues in Android 6.0.1 . hope it help .

如果问题仍然存在,请尝试将Android版本更新为Android 6.0.1中的问题。希望它有所帮助。

#2


0  

In my case, the error is hapened after changed minSdkver from 9 to 16 in the appmaniefest. I did undo minsdk version change. It is solved the error. Originally I was trying to use the calendar and date which request at least min version 16.

在我的情况下,在appmaniefest中将minSdkver从9更改为16后,错误被破坏了。我做了撤消minsdk版本更改。它解决了错误。最初我试图使用至少要求最低版本16的日历和日期。

#3


0  

Restart Android Studio and your Emulator. It will work after restart.

重新启动Android Studio和您的模拟器。重启后它会工作。

#4


0  

<application
    android:allowBackup="true"
    android:icon="@mipmap/icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainIntroActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MainActivity"/>
</application>

#5


0  

Added internet permission

添加了互联网权限

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.projectx.store">

        <uses-permission android:name="android.permission.INTERNET" />

        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".ViewAllStore" />
            <activity android:name=".ViewStore"></activity>
        </application>

    </manifest>

#1


0  

Are you testing with marshmallow version ? cause i found that issue : https://code.google.com/p/android/issues/detail?id=192357

您是否使用棉花糖版本进行测试?因为我发现了这个问题:https://code.google.com/p/android/issues/detail?id = 192357

can u try to change oncreate function from :

你可以尝试改变oncreate函数:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.<YOUR_XML_FILE_NAME>);

To this :

对此:

@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onCreate(savedInstanceState, persistentState);
    setContentView(R.layout.<YOUR_XML_FILE_NAME>);
}

if the problem persist try to update your android version its an issues in Android 6.0.1 . hope it help .

如果问题仍然存在,请尝试将Android版本更新为Android 6.0.1中的问题。希望它有所帮助。

#2


0  

In my case, the error is hapened after changed minSdkver from 9 to 16 in the appmaniefest. I did undo minsdk version change. It is solved the error. Originally I was trying to use the calendar and date which request at least min version 16.

在我的情况下,在appmaniefest中将minSdkver从9更改为16后,错误被破坏了。我做了撤消minsdk版本更改。它解决了错误。最初我试图使用至少要求最低版本16的日历和日期。

#3


0  

Restart Android Studio and your Emulator. It will work after restart.

重新启动Android Studio和您的模拟器。重启后它会工作。

#4


0  

<application
    android:allowBackup="true"
    android:icon="@mipmap/icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainIntroActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MainActivity"/>
</application>

#5


0  

Added internet permission

添加了互联网权限

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.projectx.store">

        <uses-permission android:name="android.permission.INTERNET" />

        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".ViewAllStore" />
            <activity android:name=".ViewStore"></activity>
        </application>

    </manifest>