生成的“app-release.apk”...在我的设备上不起作用,但“app-debug.apk”工作正常,
Update:
转到我的应用程序的先前版本后:
in my MainActivity
我有这个字符串:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final String PREFS_NAME = "MyPrefsFile";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
if (settings.getBoolean("my_first_time", true)) {
//the app is being launched for first time, do something
TeamModel pm;
DBHelper db;
String teamNames1= "Los Angeles Lakers";
String teamOpponent1= "Golden State Warriors";
String teamDate1= "2015-03-16 22:30";
String teamNames2= "Atlanta Hawks";
String teamOpponent2= "Sacramento Kings";
String teamDate2= "2015-03-16 20:00";
.
.
String teamNames348= "Charlotte Hornets";
String teamOpponent348= "Utah Jazz";
String teamDate348= "2015-03-16 21:00";
db = new DBHelper(getApplicationContext());
db.getWritableDatabase();
pm = new TeamModel();
pm.teamname= teamNames1;
pm.teamopponent=teamOpponent1;
pm.teamdate= teamDate1;
db.addTeam(pm);
pm.teamname= teamNames2;
pm.teamopponent=teamOpponent2;
pm.teamdate= teamDate2;
db.addTeam(pm);
.
.
pm.teamname= teamNames348;
pm.teamopponent=teamOpponent328;
pm.teamdate= teamDate348;
db.addTeam(pm);
Log.d("Comments", "First time");
settings.edit().putBoolean("my_first_time", false).commit();
从此活动中删除字符串 1 到 107(teamNames、teamOpponent、teamdate)后,应用程序在我的设备上运行良好
解释更多我的MainActivity
became:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final String PREFS_NAME = "MyPrefsFile";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
if (settings.getBoolean("my_first_time", true)) {
//the app is being launched for first time, do something
TeamModel pm;
DBHelper db;
String teamNames107= "Los Angeles Lakers"; !!!
String teamOpponent107= "Golden State Warriors"; !!!
String teamDate107= "2015-03-16 22:30"; !!!
String teamNames108= "Atlanta Hawks";
String teamOpponent108= "Sacramento Kings";
String teamDate108= "2015-03-16 20:00";
.
.
String teamNames348= "Charlotte Hornets";
String teamOpponent348= "Utah Jazz";
String teamDate348= "2015-03-16 21:00";
db = new DBHelper(getApplicationContext());
db.getWritableDatabase();
pm = new TeamModel();
pm.teamname= teamNames107;
pm.teamopponent=teamOpponent107;
pm.teamdate= teamDate107;
db.addTeam(pm);
pm.teamname= teamNames108;
pm.teamopponent=teamOpponent108;
pm.teamdate= teamDate108;
db.addTeam(pm);
.
.
pm.teamname= teamNames348;
pm.teamopponent=teamOpponent328;
pm.teamdate= teamDate348;
db.addTeam(pm);
Log.d("Comments", "First time");
settings.edit().putBoolean("my_first_time", false).commit();
怎么了?我怎样才能在不删除字符串的情况下解决这个问题?
当我尝试通过终端在我的设备上安装 app-release.apk 时出现错误日志:
Failure [INSTALL_FAILED_DEXOPT]
当我尝试在设备上安装“构建变体:发布”时,我得到了以下信息:
安装失败,因为设备可能具有与当前版本不匹配的陈旧 dexed jar(dexopt 错误)。为了继续,您必须卸载现有的应用程序。
警告:卸载将删除应用程序数据!
您想卸载现有的应用程序吗?
在“确定”或“取消”上我得到:
Failure [INSTALL_FAILED_DEXOPT]
NB:在模拟器上一切都很好