Ошибка при открытии actvity
Программа работала, но при очередной установке она стала вылетать.
UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (Sqlite code 2067)
// log:
2020-05-10 00:47:22.524 2744-16482/? E/SQLiteDatabase: Error inserting service_kind=0 source=16 tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG requires_charging=0 target_package=com.google.android.gms source_version=201515000 required_network_type=0 flex_time=1228000 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService runtime=1589053642505 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} preferred_network_type=1 required_idleness_state=0 preferred_charging_state=1 last_runtime=0 period=2458000 task_type=0 job_id=-1 user_id=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (Sqlite code 2067), (OS error - 2:No such file or directory)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:818)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:803)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1727)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1593)
at apnp.a(:com.google.android.gms@[email protected] (040306-306758586):76)
at apne.a(:com.google.android.gms@[email protected] (040306-306758586):173)
at apne.a(:com.google.android.gms@[email protected] (040306-306758586):21)
at apne.a(:com.google.android.gms@[email protected] (040306-306758586):167)
at apjn.run(:com.google.android.gms@[email protected] (040306-306758586):8)
at ssd.b(:com.google.android.gms@[email protected] (040306-306758586):12)
at ssd.run(:com.google.android.gms@[email protected] (040306-306758586):7)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at sye.run(:com.google.android.gms@[email protected] (040306-306758586):0)
at java.lang.Thread.run(Thread.java:776)
2020-05-10 00:47:22.998 1731-3738/? E/LocSvc_libulp: I/int ulp_msg_process_system_update(const UlpSystemEvent): systemEvent:5
2020-05-10 00:47:22.998 1731-3738/? E/LocSvc_libulp: I/===> int ulp_brain_turn_onoff_dr_provider() line 848
2020-05-10 00:47:22.998 1731-3738/? E/LocSvc_libulp: I/===> int ulp_dr_stop_engine() line 235
2020-05-10 00:47:22.998 1731-3738/? E/LocSvc_libulp: I/int ulp_msg_process_start_req(), at ulp state = 1
2020-05-10 00:47:22.998 1731-2527/? E/LocSvc_api_v02: I/---> locClientSendReq line 2069 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
2020-05-10 00:47:23.001 1731-12515/? E/LocSvc_ApiV02: I/<--- void globalRespCb(locClientHandleType, uint32_t, const locClientRespIndUnionType, uint32_t, void *) line 140 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
2020-05-10 00:47:23.001 1731-3738/? E/LocSvc_libulp: I/int ulp_brain_process_zpp_position_report(const enum loc_sess_status, LocPosTechMask, UlpLocation *), report ZPP position to providers,report_position = 1
2020-05-10 00:47:23.001 1731-3738/? E/LocSvc_libulp: I/===> int ulp_brain_turn_onoff_dr_provider() line 848
2020-05-10 00:47:23.001 1731-3738/? E/LocSvc_libulp: I/===> int ulp_dr_stop_engine() line 235
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DatabaseHelper extends SQLiteOpenHelper {
private static String DB_NAME = "app_database.db";
private static String DB_PATH = "";
public static String LESSONS1 = "MondayLessons";
public static String LESSONS2 = "TuesdayLessons";
public static String LESSONS3 = "WednesdayLessons";
public static String LESSONS4 = "ThursdayLessons";
public static String LESSONS5 = "FridayLessons";
public static String LESSONS6 = "SaturdayLessons";
public static String LESSONS7 = "SundayLessons";
public static String TIMES0 = "SameDaysTimes";
public static String TIMES1 = "MondayTimes";
public static String TIMES2 = "TuesdayTimes";
public static String TIMES3 = "WednesdayTimes";
public static String TIMES4 = "ThursdayTimes";
public static String TIMES5 = "FridayTimes";
public static String TIMES6 = "SaturdayTimes";
public static String TIMES7 = "SundayTimes";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_NAME_LESSON = "NameLesson";
public static final String COLUMN_START_TIME = "StartTime";
public static final String COLUMN_FINISH_TIME = "FinishTime";
//def ver = 2
private static final int DB_VERSION = 2;
private DatabaseHelper mDBHelper;
private SQLiteDatabase mDataBase;
private final Context mContext;
private boolean mNeedUpdate = false;
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
if (android.os.Build.VERSION.SDK_INT >= 17)
DB_PATH = context.getApplicationInfo().dataDir + "/databases/";
else
DB_PATH = "/data/data/" + context.getPackageName() + "/databases/";
this.mContext = context;
copyDataBase();
this.getReadableDatabase();
}
public void updateDataBase() {
if (mNeedUpdate) {
File dbFile = new File(DB_PATH + DB_NAME);
if (dbFile.exists())
dbFile.delete();
copyDataBase();
mNeedUpdate = false;
}
}
private boolean checkDataBase() {
File dbFile = new File(DB_PATH + DB_NAME);
return dbFile.exists();
}
private void copyDataBase() {
if (!checkDataBase()) {
this.getReadableDatabase();
this.close();
try {
copyDBFile();
} catch (IOException mIOException) {
throw new Error("ErrorCopyingDataBase");
}
}
}
private void copyDBFile() throws IOException {
// TimesPlacesFiller();
InputStream mInput = mContext.getAssets().open(DB_NAME);
//InputStream mInput = mContext.getResources().openRawResource(R.raw.info);
OutputStream mOutput = new FileOutputStream(DB_PATH + DB_NAME);
byte[] mBuffer = new byte[1024];
int mLength;
while ((mLength = mInput.read(mBuffer)) > 0)
mOutput.write(mBuffer, 0, mLength);
mOutput.flush();
mOutput.close();
mInput.close();
}
public boolean openDataBase() throws SQLException {
mDataBase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, SQLiteDatabase.CREATE_IF_NECESSARY);
return mDataBase != null;
}
@Override
public synchronized void close() {
if (mDataBase != null)
mDataBase.close();
super.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion > oldVersion)
mNeedUpdate = true;
}
}
// gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId 'adwantay.studio.application'
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-ads:19.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
// butter knife
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.material:material:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
ext {
**** = 'adwantay.studio.****'
**** = ****
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}