Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova build | Run failed - compileDebugJavaWithJavac

I have a problem with building my Android platform on Apache Cordova.

Version numbers:

  • Android @5.0.1 (Samsung galaxy S4)
  • Cordova @6.1.1 (updated from 5.1.1 on 07/04/2016)
  • Ionic @1.7.14
  • Windows @7

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:

  • 23.0.3
  • 23.0.2
  • 23.0.1
  • 22.0.1
  • 21.1.2
  • 20
  • 19.1

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.

like image 717
Mr.wiseguy Avatar asked Apr 12 '16 09:04

Mr.wiseguy


1 Answers

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.

like image 89
Elvis Xia - MSFT Avatar answered Sep 21 '22 14:09

Elvis Xia - MSFT