1

I'm doing an app that requires Spotify in Android. But when i run libSpotify "sp_session_create" i get a SIGSEGV. The version of libSpotify that i'm using is v12.1.51 BETA - For android ARM

sp_error initialise(const char * asKey,
                    const char * asFolder,
                    const char * asUserAgent,
                    bool isPlaylistCompressed,
                    bool isMetadataOnPlaylist,
                    bool isPlaylistInitialUnload)
{
    sp_session_callbacks asCallbacks;
    memset(&asCallbacks, 0, sizeof(asCallbacks));

    asCallbacks.logged_in                    = Callback::onSessionLogin;
    asCallbacks.log_message                  = Callback::onSessionLog;

    sp_session_config asConfiguration;
    memset(&asConfiguration, 0, sizeof(asConfiguration));

    std::string asDirectory = asFolder;
    auto asDirectoryCache   = asDirectory + "/cache";
    auto asDirectorySetting = asDirectory + "/setting";

    const auto asApplicationKey = "Key goes here...";

    asConfiguration.api_version                      = SPOTIFY_API_VERSION;
    asConfiguration.application_key                  = asApplicationKey;
    asConfiguration.application_key_size             = sizeof(asApplicationKey);
    asConfiguration.cache_location                   = asDirectoryCache.c_str();
    asConfiguration.settings_location                = asDirectorySetting.c_str();
    asConfiguration.user_agent                       = asUserAgent;
    asConfiguration.compress_playlists               = isPlaylistCompressed;
    asConfiguration.dont_save_metadata_for_playlists = isMetadataOnPlaylist;
    asConfiguration.initially_unload_playlists       = isPlaylistInitialUnload;
    asConfiguration.userdata                         = this;
    asConfiguration.callbacks                        = &asCallbacks;

    sp_error asError = sp_session_create(&asConfiguration, &_asSession);

    __android_log_print(ANDROID_LOG_VERBOSE, LIBRARY_NAME, "PASSED");

    return asError;
}
Agustin Alvarez
  • 349
  • 1
  • 2
  • 11

2 Answers2

0

Edit: Spotify's new Android SDK is released! You should strongly consider moving your project to the new SDK, since libspotify is now deprecated for that platform.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
  • Hello!, thanks for the response after some time i was able to fix it and now is not crashing anymore :D, but yeah libSpotify is a pain when it comes to Android (Now i have switch to WebAPI for metadata and libSpotify for offline-mode stuff) – Agustin Alvarez Jun 19 '14 at 17:52
  • does the new SDK support Offline playback? (Main reason why im using libSpotify) – Agustin Alvarez Jun 27 '14 at 08:01
  • 1
    @AgustinAlvarez not yet, but it's a planned feature and is coming soon. – Nik Reiman Jun 27 '14 at 08:03
0

The crash was due to cache folder.

Agustin Alvarez
  • 349
  • 1
  • 2
  • 11