@@ -78,13 +78,13 @@ public String getName() {
78
78
// Success
79
79
80
80
// 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 ) {
82
82
if (!isAlive ()) {
83
83
return false ;
84
84
}
85
85
bringLauncherToFront ();
86
86
try {
87
- final ProcessResult installResult = adb ("install" , "-r" , apkPath );
87
+ final ProcessResult installResult = adb ("install" , "-r" , build . getPathForAPK () );
88
88
if (!installResult .succeeded ()) {
89
89
status .statusError ("Could not install the sketch." );
90
90
System .err .println (installResult );
@@ -94,6 +94,12 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
94
94
for (final String line : installResult ) {
95
95
if (line .startsWith ("Failure" )) {
96
96
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
+
97
103
System .err .println (line );
98
104
}
99
105
}
@@ -109,6 +115,16 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
109
115
return false ;
110
116
}
111
117
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
+
112
128
113
129
// different version that actually runs through JDI:
114
130
// http://asantoso.wordpress.com/2009/09/26/using-jdb-with-adb-to-debugging-of-android-app-on-a-real-device/
0 commit comments