我在某些设备上(Android 7的Nexus 5x)遇到了非常奇怪的情况:当我清除其数据并卸载它,然后使用Studio安装它时,该应用程序未被初始化,但它使用的是1月24日的数据!我尝试了同样的步骤,使用平板电脑,但该应用程序没有数据。
我已经重复了这个过程很多次,清理了我的项目,多次重新构建它,但它总是从1月24日的数据开始(数据库和共享首选项都是如此)。
我甚至尝试了adb shell和run as来清除数据:
bullhead:/data/data/lelisoft.com.lelimath.debug $ ls -l databases/
total 232
-rw-rw---- 1 u0_a259 u0_a259 98304 2017-02-05 11:03 lelimath.sqlite
-rw------- 1 u0_a259 u0_a259 16928 2017-02-05 11:03 lelimath.sqlite-journal
我删除了它们,应用程序似乎变得空无一物 - 直到我将其删除并重新安装 - 1月24日又回来了。
这是一个记录的开始:
$ adb shell am start -n "lelisoft.com.lelimath.debug/lelisoft.com.lelimath.activities.DashboardActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: lelisoft.com.lelimath.debug | lelisoft.com.lelimath.debug.test
I/InstantRun: Instant Run Runtime started. Android package is lelisoft.com.lelimath.debug, real application class is lelisoft.com.lelimath.helpers.LeliMathApp.
D/l.c.l.h.LeliMathApp: onCreate()
D/l.c.l.h.BalanceHelper: Current points balance: 234
这是从调试器获取的数据库位置:
/data/user/0/lelisoft.com.lelimath.debug/databases/lelimath.sqlite
Gradle:
android {
signingConfigs {
}
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "lelisoft.com.lelimath"
resValue 'string', 'app_name', 'LeliMath'
minSdkVersion 16
targetSdkVersion 24
versionCode 300
versionName '3.0.0'
resValue "string", "app_build_number", getDate();
resValue "string", "app_version", versionName;
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
resValue 'string', 'app_name', 'LeliMath DEV'
}
}
清单部分:
<application
android:name=".helpers.LeliMathApp"
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
我不想恢复出厂设置来清除这些数据。我认为这些数据不在我的构建中。当安装时,我的平板电脑上的应用程序为空,我也没有添加它们。