Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android-maven-plugin: deploy method that does not delete SharedPreferences

I built an android project that set up with android-maven-plugin. When I execute android:deploy and run the program, SharedPreferences always initialized.

Is there a way to deploy my project to AVD without deleting SharedPreferences storage?

P.S.

I use Intellij IDEA and noticed that its native android run/debug support does not delete SharedPreferences. However, after I add scala support on my project, IDE reports "Too many methods: 112423; max is 65536" error when I run the application. Perhaps it is due to lack of proguard preprocessing. If there are a way to apply proguard before run the android app with Intellij IDEA android support, it would be an equally effective solution.

like image 521
pocorall Avatar asked Oct 07 '12 16:10

pocorall


1 Answers

I think your app is being uninstalled before being reinstalled again - this would cause you to lose your SharedPreferences values. This can be controlled with the Android Maven plugin parameter undeployBeforeDeploy.

I just tried to create a Maven project with the android-quickstart archetype and found that it automatically added the following line to my POM:

<undeployBeforeDeploy>true</undeployBeforeDeploy>

Try to set this to false and try again.

If you have it set to true, it prints this line in the console when you run mvn android:deploy:

[INFO] Successfully uninstalled [package] from [device]
like image 191
antonyt Avatar answered Nov 15 '22 00:11

antonyt