Reputation: 4252
I have a problem with building my Android platform on Apache Cordova.
Version numbers:
I could build my project yesterday, but since today I get errors when trying to build or run my cordova app. I have tried to remove and add my android platform, but that didn't work (it only made thing worse).
Execution failed
When I run "Cordova build android" or "Cordova run android" I get the following error:
Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
The stacktrace gives the following:
:CordovaLib:compileDebugJavaWithJavac C:\Users\me\Desktop\myProjects\testProject\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:222: error: cannot find symbol getActivity().requestPermissions(permissions, requestCode);
I cannot seem to resolve this error. I have a valid java path in my environment variables and I have installed the following Android SDK build tools:
What I tried
I tried cordova platform add [email protected], but that gives me unknown platform version. So I have to set it to version 21 manually in the Android manifest and project.properties.
Also if I run cordova platform add [email protected] cordova somehow overrides this and installs the platform for android version 23 (6.0).
I tried downgrading to Cordova version 5.1.1, but that still gave me the same error.
I tried changing the Java path, with no result.
I updated my Android SDK tools and Android SDK platform tools, No difference.
Solution
It seemed that my npm_cache was corrupt. I had to remove it, so that it was recreated by Cordova. After this I could build and run again. File location: C:\Users\.cordova\lib and then remove the npm_cache folder.
Upvotes: 5
Views: 16936
Reputation: 10831
There might be something wrong with your android platform template. Try deleting "users/user/.cordova/lib/npm_cache" folder,which caches your platform files.
After that, remove the platform of your project and add it again.
Upvotes: 5