Android build failed after Ionic Native Crop plugin installed

I’m trying to use the Ionic Native Crop plugin on my app, but without success.

Before the plugin installation all works fine when I run ionic cordova run android --device, but, when I install the plugin with:

ionic cordova plugin add cordova-plugin-crop

and

npm install --save @ionic-native/crop

the following error occurs when I run ionic cordova run android --device:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:processDebugResources’.

com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    FAILED

BUILD FAILED

Total time: 1 mins 15.829 secs
Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:processDebugResources’.

com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova run android --device (exit code 1).

If I uninstall the plugin, all works fine again.

ionic info output:

cli packages: (C:\Users\User\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.0
Cordova Platforms  : android 6.3.0 browser 5.0.1 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Node : v6.11.2
npm  : 3.10.10
OS   : Windows 10

Environment Variables:

ANDROID_HOME : C:\Android\android-sdk

Misc:

backend : pro

ionic cordova requirements output:

Requirements check results for android:
Error: Cannot read property ‘forEach’ of undefined

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
‘avdmanager’ is not recognized as an internal command
or external, an operable program or a batch file.
Gradle: installed C:\Program Files\Android\Android Studio1\gradle\gradle-4.1\bin\gradle

I found it strange that when I run ionic cordova requirements the Android target is not installed (maybe it’s a bug, since a few days ago my Cordova Platforms was none and now contains the information), but anyway everything works fine, less when I install the crop plugin.

Do I have to search for another plugin or is there some way to solve this?

I don’t have my computer nearby so can’t check my config.xml, but is there a target/ min SDK for Android in that file?

Strange that the virtual device manager is being mentioned (or is that normal with run android —device?)

In config.xml, the only line that contains any information about the SDK has: <preference name="android-minSdkVersion" value="16" />. I’m using --device because my Android device are conected by USB cable (following the docs, it’s normal)

My only thought is that perhaps a targetSdk can be added to config.xml (in addition to minSdk). I know from experience using Android Studio that a targetSdk is a necessity and has a big part in how / if certain plugins work, how / if certain imports work.

I understand. But I believe that if that were the case, every page of the plugins would have information about the required SDK (and the config.xml would have the targetSdk). I think it is some version mismatch of some function of Ionic itself, or even of Build Tools with the plugin, but I don’t know where to search/check/change or if the error refers to something else.

That’s a very good point