@@ -78,13 +78,13 @@ public String getName() {
7878 // Success
7979
8080 // safe to just always include the -r (reinstall) flag
81- public boolean installApp (final String apkPath , final RunnerListener status ) {
81+ public boolean installApp (final AndroidBuild build , final RunnerListener status ) {
8282 if (!isAlive ()) {
8383 return false ;
8484 }
8585 bringLauncherToFront ();
8686 try {
87- final ProcessResult installResult = adb ("install" , "-r" , apkPath );
87+ final ProcessResult installResult = adb ("install" , "-r" , build . getPathForAPK () );
8888 if (!installResult .succeeded ()) {
8989 status .statusError ("Could not install the sketch." );
9090 System .err .println (installResult );
@@ -94,6 +94,12 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
9494 for (final String line : installResult ) {
9595 if (line .startsWith ("Failure" )) {
9696 errorMsg = line .substring (8 );
97+
98+ if (line .contains ("INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES" )) {
99+ boolean removeResult = removeApp (build .getPackageName ());
100+ if (removeResult ) return installApp (build , status );
101+ }
102+
97103 System .err .println (line );
98104 }
99105 }
@@ -109,6 +115,16 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
109115 return false ;
110116 }
111117
118+ public boolean removeApp (String packageName ) throws IOException , InterruptedException {
119+ final ProcessResult removeResult = adb ("uninstall" , packageName );
120+
121+ if (!removeResult .succeeded ()) {
122+ return false ;
123+ }
124+
125+ return true ;
126+ }
127+
112128
113129 // different version that actually runs through JDI:
114130 // http://asantoso.wordpress.com/2009/09/26/using-jdb-with-adb-to-debugging-of-android-app-on-a-real-device/
0 commit comments