question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build failed: Task :app:compileDebugJavaWithJavac FAILED

See original GitHub issue

I’m having issues building the app for Android. FYI: I use Ionic but it shouldn’t matter since this is cordova/java-related.

I tried using cordova-android 6.3, 6.4, 7.1 & 8.0 but to no avail. I always get the same build errors. So I’m starting to wonder if there’s something wrong with my config. I get this error both on Windows 10 & Mac OS. I have the same config / versions on both setup.

Here’s the build logs:

BUILD FAILED in 2m 59s
> Task :app:compileDebugJavaWithJavac FAILED
24 actionable tasks: 24 executed
C:\Users\anon\Workshop\polycast-frontend\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: C:\Users\anon\Workshop\polycast-frontend\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\anon\Workshop\polycast-frontend\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:54: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\anon\Workshop\polycast-frontend\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:56: error: cannot find symbol
    super.onPlayFromMediaId(mediaId, extras);
         ^
  symbol: method onPlayFromMediaId(String,Bundle)
C:\Users\anon\Workshop\polycast-frontend\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:72: error: cannot find symbol
                this.mediaSessionCompat.setMediaButtonReceiver(this.mediaButtonPendingIntent);
                                       ^
  symbol:   method setMediaButtonReceiver(PendingIntent)
  location: variable mediaSessionCompat of type MediaSessionCompat
C:\Users\anon\Workshop\polycast-frontend\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:80: error: cannot find symbol
                this.mediaSessionCompat.setMediaButtonReceiver(null);
                                       ^
  symbol:   method setMediaButtonReceiver(<null>)
  location: variable mediaSessionCompat of type MediaSessionCompat
C:\Users\anon\Workshop\polycast-frontend\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:103: error: no suitable constructor found for MediaSessionCompat(Context,String,<null>,PendingIntent)
                this.mediaSessionCompat = new MediaSessionCompat(context, "cordova-music-controls-media-session", null, this.mediaButtonPendingIntent);
                                          ^
    constructor MediaSessionCompat.MediaSessionCompat(Context,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor MediaSessionCompat.MediaSessionCompat(MediaSessionImpl) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Here’s my Windows 10 config:

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

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 8.1.2 (cordova-lib@8.1.1)

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.4.0 ios 4.5.5
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.11.1
    npm  : 5.6.0
    OS   : Windows 10

EDIT: Here’s my config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.brainpad.polycast" version="0.0.41" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Polycast</name>
    <description>Get informed and entertained.</description>
    <author email="support@brainpad.org" href="https://brainpad.org/">Brainpad Consulting</author>
    <content src="index.html" />
    <access origin="*" />
    <access launch-external="yes" origin="ftp://*" />
    <access launch-external="yes" origin="http://*" />
    <access launch-external="yes" origin="https://*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-navigation href="http://192.168.1.106:8100" sessionid="e35752d5" />
    <allow-navigation href="http://192.168.1.135:8100" />
    <allow-navigation href="http://192.168.56.1:8100" />
    <allow-navigation href="http://192.168.1.112:8100" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <config-file mode="add" parent="ITSAppUsesNonExemptEncryption" target="*-Info.plist">
            <false />
        </config-file>
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2732" />
        <splash height="1536" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="2048" />
        <splash height="768" src="resources/ios/splash/Default-Portrait~ipad.png" width="1024" />
        <splash height="2732" src="resources/ios/splash/Default@2x~ipad~anyany.png" width="2732" />
        <splash height="2732" src="resources/ios/splash/Default@2x~ipad~comany.png" width="1278" />
        <splash height="640" src="resources/ios/splash/Default@2x~iphone.png" width="960" />
        <splash height="1334" src="resources/ios/splash/Default@2x~iphone~anyany.png" width="1334" />
        <splash height="1334" src="resources/ios/splash/Default@2x~iphone~comany.png" width="750" />
        <splash height="750" src="resources/ios/splash/Default@2x~iphone~comcom.png" width="1334" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <splash height="2208" src="resources/ios/splash/Default@3x~iphone~anyany.png" width="2208" />
        <splash height="1242" src="resources/ios/splash/Default@3x~iphone~anycom.png" width="2208" />
        <splash height="2208" src="resources/ios/splash/Default@3x~iphone~comany.png" width="1242" />
        <splash height="320" src="resources/ios/splash/Default~iphone.png" width="480" />
    </platform>
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
    <plugin name="cordova-plugin-device" spec="^1.1.4" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-ionic-webview" spec="^1.2.1" />
    <plugin name="cordova-plugin-app-version" spec="^0.1.9" />
    <plugin name="cordova-plugin-nativestorage" spec="^2.3.2" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
    <plugin name="cordova-plugin-android-support-v4" spec="^21.0.1" />
    <plugin name="cordova-plugin-music-controls" spec="https://github.com/homerours/cordova-music-controls-plugin.git" />
    <engine name="ios" spec="4.5.5" />
    <engine name="android" spec="6.4.0" />
</widget>

And my package.json:

{
  "name": "podcast-player",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/compiler-cli": "5.0.0",
    "@angular/core": "5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@ionic-native/app-version": "^4.20.0",
    "@ionic-native/core": "4.3.2",
    "@ionic-native/music-controls": "^4.20.0",
    "@ionic-native/native-storage": "^4.20.0",
    "@ionic-native/splash-screen": "4.3.2",
    "@ionic-native/status-bar": "4.3.2",
    "@ionic/storage": "2.1.3",
    "cordova-android": "6.4.0",
    "cordova-ios": "4.5.5",
    "cordova-plugin-android-support-v4": "^21.0.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-music-controls": "git+https://github.com/homerours/cordova-music-controls-plugin.git",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.1",
    "feedparser": "^2.2.1",
    "ionic-angular": "3.9.2",
    "ionic-audio": "github:tbergeron/ionic-audio#3.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.0",
    "typescript": "~2.6.2"
  },
  "description": "podcast-player: An Ionic project",
  "cordova": {
    "platforms": [
      "ios",
      "android"
    ],
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-nativestorage": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-android-support-v4": {},
      "cordova-plugin-music-controls": {}
    }
  }
}

Anyone sees anything wrong? Why am I getting these errors?

I used to have Android v4 build errors, then I installed cordova-plugin-android-support-v4 and they went away. Now I’m stuck on these build errors. Any ideas will be welcome! Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15

github_iconTop GitHub Comments

5reactions
NorthFredcommented, Mar 4, 2019

@tbergeron: The plugin has a slightly different name: “cordova-plugin-android-support-v4-jar”. It’s a subtle difference 😃 Please try with that one!

1reaction
tobikacommented, Apr 16, 2019

@rastographics once you are in android studio, right click on app then Open Module Settings then Dependencies

Screenshot from 2019-04-16 15-02-36

Read more comments on GitHub >

github_iconTop Results From Across the Web

Execution Failed for task :app:compileDebugJavaWithJavac in ...
Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio · Go to Run -> Edit Configuration -> Gradle -> + Gradle -> Tasks:build, Script ......
Read more >
Fix "Execution Failed for task :app ... - GeeksforGeeks
Fix “Execution Failed for task :app:compileDebugJavaWithJavac” in Android Studio · Method: #1 Try updating your buildToolsVersion to “23.0.
Read more >
Task :app:compileDebugJavaWithJavac FAILED - Cannot run ...
Task :app:compileDebugJavaWithJavac FAILED - Cannot run on Android (works fine on iOS) #67677 ... FAILURE: Build failed with an exception.
Read more >
Execution Failed for task app compileDebugJavaWithJavac in ...
I am developing an Android App in Android Studio. Not quite sure what went wrong. I was successfully building a few days ago....
Read more >
Wizard: Mobile Application project build failing with gradle 7.0+
Now project building failing with following error: Execution failed for task ':shared:compileDebugJavaWithJavac'. > Failed to query the value of task ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found