@@ -359,8 +359,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
359359
360360 public removePluginNativeCode ( pluginData : IPluginData ) : void {
361361 try {
362- this . $fs . deleteDirectory ( path . join ( this . platformData . projectRoot , "configurations" , pluginData . name ) ) ;
363- this . $fs . deleteDirectory ( path . join ( this . platformData . projectRoot , "src" , pluginData . name ) ) ;
362+ // check whether the dependency that's being removed has native code
363+ let pluginConfigDir = path . join ( this . platformData . projectRoot , "configurations" , pluginData . name ) ;
364+ if ( this . $fs . exists ( pluginConfigDir ) ) {
365+ this . cleanProject ( this . platformData . projectRoot , [ ] ) . wait ( ) ;
366+ }
364367 } catch ( e ) {
365368 if ( e . code === "ENOENT" ) {
366369 this . $logger . debug ( "No native code jars found: " + e . message ) ;
@@ -388,16 +391,23 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
388391
389392 let buildOptions = this . getBuildOptions ( ) ;
390393
391- buildOptions . unshift ( "clean" ) ;
392-
393394 let projectRoot = this . platformData . projectRoot ;
395+ this . cleanProject ( projectRoot , buildOptions ) . wait ( ) ;
396+ }
397+ return Future . fromResult ( ) ;
398+ }
399+
400+ private cleanProject ( projectRoot : string , options : string [ ] ) : IFuture < void > {
401+ return ( ( ) => {
402+ options . unshift ( "clean" ) ;
403+
394404 let gradleBin = path . join ( projectRoot , "gradlew" ) ;
395405 if ( this . $hostInfo . isWindows ) {
396406 gradleBin += ".bat" ;
397407 }
398- this . spawn ( gradleBin , buildOptions , { stdio : "inherit" , cwd : this . platformData . projectRoot } ) . wait ( ) ;
399- }
400- return Future . fromResult ( ) ;
408+
409+ this . spawn ( gradleBin , options , { stdio : "inherit" , cwd : this . platformData . projectRoot } ) . wait ( ) ;
410+ } ) . future < void > ( ) ( ) ;
401411 }
402412
403413 public deploy ( deviceIdentifier : string ) : IFuture < void > {
0 commit comments