How to use musicControls


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

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

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
[ERROR] An error occurred while running subprocess cordova.

        cordova run android exited with exit code 1.

1 Like

you can install java version JDK8 and Gradle version for 4.6 +

Thank you for your support. I already using jdk 8 and gradle 5.0. Still I am getting same error. Help me in this.

Please share your getting error

FAILURE: Build failed with an exception.

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

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

* Get more help at https://help.gradle.org

BUILD FAILED in 35s
cmd: Command failed with exit code 1 Error output:
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:5: error: package android.support.v4.media.session does not exist
import android.support.v4.media.session.MediaSessionCompat;
                                       ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:10: error: package MediaSessionCompat does not exist
public class MediaSessionCallback extends MediaSessionCompat.Callback {
                                                            ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:15: error: package android.support.v4.media does not exist
import android.support.v4.media.MediaMetadataCompat;
                               ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:16: error: package android.support.v4.media.session does not exist
import android.support.v4.media.session.MediaSessionCompat;
                                       ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:17: error: package android.support.v4.media.session does not exist
import android.support.v4.media.session.PlaybackStateCompat;
                                       ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:45: error: cannot find symbol
        private MediaSessionCompat mediaSessionCompat;
                ^
  symbol:   class MediaSessionCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:18: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:20: error: cannot find symbol
    super.onPlay();
    ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:27: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:29: error: cannot find symbol
    super.onPause();
    ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:36: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:38: error: cannot find symbol
    super.onSkipToNext();
    ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:45: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:47: error: cannot find symbol
    super.onSkipToPrevious();
    ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\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\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:56: error: cannot find symbol
    super.onPlayFromMediaId(mediaId, extras);
    ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:59: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:64: error: cannot find symbol
      return super.onMediaButtonEvent(mediaButtonIntent);
             ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MediaSessionCallback.java:131: error: cannot find symbol
          return super.onMediaButtonEvent(mediaButtonIntent);
                 ^
  symbol:   variable super
  location: class MediaSessionCallback
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:103: error: cannot find symbol
                this.mediaSessionCompat = new MediaSessionCompat(context, "cordova-music-controls-media-session", null, this.mediaButtonPendingIntent);
                                              ^
  symbol:   class MediaSessionCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:104: error: cannot find symbol
                this.mediaSessionCompat.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
                                                 ^
  symbol:   variable MediaSessionCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:104: error: cannot find symbol
                this.mediaSessionCompat.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
                                                                                                 ^
  symbol:   variable MediaSessionCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:107: error: cannot find symbol
                setMediaPlaybackState(PlaybackStateCompat.STATE_PAUSED);
                                      ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:144: error: package MediaMetadataCompat does not exist
                         final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();
                                                  ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:144: error: package MediaMetadataCompat does not exist
                         final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();
                                                                                                    ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:152: error: cannot find symbol
                                        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, infos.track);
                                                                  ^
  symbol: variable MediaMetadataCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:154: error: cannot find symbol
                                        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, infos.artist);
                                                                  ^
  symbol: variable MediaMetadataCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:156: error: cannot find symbol
                                        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, infos.album);
                                                                  ^
  symbol: variable MediaMetadataCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:160: error: cannot find symbol
                                                metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, art);
                                                                          ^
  symbol: variable MediaMetadataCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:161: error: cannot find symbol
                                                metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art);
                                                                          ^
  symbol: variable MediaMetadataCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:168: error: cannot find symbol
                                                setMediaPlaybackState(PlaybackStateCompat.STATE_PLAYING);
                                                                      ^
  symbol: variable PlaybackStateCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:170: error: cannot find symbol
                                                setMediaPlaybackState(PlaybackStateCompat.STATE_PAUSED);
                                                                      ^
  symbol: variable PlaybackStateCompat
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:182: error: cannot find symbol
                                setMediaPlaybackState(PlaybackStateCompat.STATE_PLAYING);
                                                      ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:184: error: cannot find symbol
                                setMediaPlaybackState(PlaybackStateCompat.STATE_PAUSED);
                                                      ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:225: error: package PlaybackStateCompat does not exist
                PlaybackStateCompat.Builder playbackstateBuilder = new PlaybackStateCompat.Builder();
                                   ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:225: error: package PlaybackStateCompat does not exist
                PlaybackStateCompat.Builder playbackstateBuilder = new PlaybackStateCompat.Builder();
                                                                                          ^
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:226: error: cannot find symbol
                if( state == PlaybackStateCompat.STATE_PLAYING ) {
                             ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:227: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                        ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:227: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:227: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                                                   ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:227: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                                                                                             ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:228: error: cannot find symbol
                                PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID |
                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:229: error: cannot find symbol
                                PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH);
                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:230: error: cannot find symbol
                        playbackstateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);
                                                             ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:232: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                        ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:232: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:232: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                                                  ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:232: error: cannot find symbol
                        playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                                                                                                                                                            ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:233: error: cannot find symbol
                                PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID |
                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:234: error: cannot find symbol
                                PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH);
                                ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControls.java:235: error: cannot find symbol
                        playbackstateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 0);
                                                             ^
  symbol:   variable PlaybackStateCompat
  location: class MusicControls
Note: C:\Users\pasupathi-k\Desktop\MyApptow\platforms\android\app\src\main\java\com\homerours\musiccontrols\MusicControlsNotification.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
51 errors

I am having same issue after installation of music controls plugin have you got any solution?

remove this plugin

ionic cordova plugin rm cordova-plugin-music-controls

add this plugin

ionic cordova plugin add https://github.com/amitkhare/cordova-music-controls-plugin --save
2 Likes

How would using an older version of that plugin be the solution?
The original one (the one bound to the npm package) has updates from 3 months ago, the one you suggest hasn’t been updated for more than a year…

Anyone found a solution to this yet? I would like to use the most secure / updated code but I still get this error on Mac OS but not on Windows 10.

Is there still ANYBODY alive in here?! I really WANT to use Ionic but it seems harder and harder as I get near release to have everything compile the right way all the time. There’s always something blowing up.

WHY does everybody refers to this 3 years old repo when NPM points to this one; which is the most up-to-date?! I see this everywhere, it fixes NOTHING and is just a waste of time. Please EXPLAIN when telling people to simply swap sources. It’s borderline a security concern…

I get this error
I have androidx and androidx-adapter plugins too

BUILD FAILED in 6s
/platforms/android/gradlew: Command failed with exit code 1 Error output:
/platforms/android/app/src/main/java/com/homerours/musiccontrols/MusicControls.java:15: error: package android.support.v4.media does not exist
import android.support.v4.media.MediaMetadataCompat;

Ionic:

ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.8
@ionic/app-scripts : 3.2.4

Cordova:

cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : no whitelisted plugins (25 plugins total)

System:

Android SDK Tools : 26.1.1
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001

cordova-android-play-services-gradle-release 4.0.0 “cordova-android-play-services-gradle-release”
cordova-plugin-add-swift-support 2.0.2 “AddSwiftSupport”
cordova-plugin-advanced-http 1.11.1 “Advanced HTTP plugin”
cordova-plugin-androidx 1.0.2 “cordova-plugin-androidx”
cordova-plugin-androidx-adapter 1.1.0 “cordova-plugin-androidx-adapter”
cordova-plugin-app-version 0.1.9 “AppVersion”
cordova-plugin-appminimize 1.0.1 “AppMinimize”
cordova-plugin-apprate 1.4.0 “AppRate”
cordova-plugin-background-mode 0.7.2 “BackgroundMode”
cordova-plugin-datepicker 0.9.3 “DatePicker”
cordova-plugin-device 2.0.3 “Device”
cordova-plugin-dialogs 2.0.2 “Notification”
cordova-plugin-file 6.0.2 “File”
cordova-plugin-firebasex 4.0.0 “Google Firebase Plugin”
cordova-plugin-globalization 1.11.0 “Globalization”
cordova-plugin-google-analytics 1.8.6 “Google Universal Analytics Plugin”
cordova-plugin-inappbrowser 2.0.2 “InAppBrowser”
cordova-plugin-media 5.0.3 “Media”
cordova-plugin-music-controls 2.2.0 “MusicControls”
cordova-plugin-nativestorage 2.3.2 “NativeStorage”
cordova-plugin-screen-orientation 3.0.2 “Screen Orientation”
cordova-plugin-splashscreen 5.0.3 “Splashscreen”
cordova-plugin-statusbar 2.4.3 “StatusBar”
cordova-plugin-whitelist 1.3.4 “Whitelist”
cordova-sqlite-storage 3.2.1 “Cordova sqlite storage plugin - cordova-sqlite-storage plugin version”
cordova-support-google-services 1.3.1 “cordova-support-google-services”
es6-promise-plugin 4.2.2 “Promise”
ionic-plugin-keyboard 2.2.1 “Keyboard”