SDL_Mixer Android Studio Build Error

I’m using the new Android Studio project provided in SDL. When adding SDL_mixer I get an error with libmpg123 about “shared library text segment is not shareable”. I haven’t been able to avoid this error. I also get errors when setting SUPPORT_MP3_MPG123 to false.
I didn’t have any problems adding SDL_image and SDL_ttf.

Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/James/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/James/Downloads/SDL/android-project/app/jni/Android.mk NDK_APPLICATION_MK=/Users/James/Downloads/SDL/android-project/app/jni/Application.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=/Users/James/Downloads/SDL/android-project/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/James/Downloads/SDL/android-project/app/build/intermediates/ndkBuild/debug/lib APP_PLATFORM=android-14 /Users/James/Downloads/SDL/android-project/app/build/intermediates/ndkBuild/debug/obj/local/x86/libmain.so}
  [x86] SharedLibrary  : libmpg123.so
  /Users/James/Library/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: warning: shared library text segment is not shareable
  /Users/James/Library/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: treating warnings as errors
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [/Users/James/Downloads/SDL/android-project/app/build/intermediates/ndkBuild/debug/obj/local/x86/libmpg123.so] Error 1

This should be fixed:

The newest commit doesn’t build for me. I get the following errors about an undeclared identifier ‘defopt’.

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:generateJsonModelDebug
:app:externalNativeBuildDebug
Build SDL2_mixer mips
[mips] Compile        : SDL2_mixer <= effect_position.c
[mips] Compile        : SDL2_mixer <= effect_stereoreverse.c
[mips] Compile        : SDL2_mixer <= effects_internal.c
[mips] Compile        : SDL2_mixer <= load_aiff.c
[mips] Compile        : SDL2_mixer <= load_voc.c
[mips] Compile        : SDL2_mixer <= mixer.c
[mips] Compile        : SDL2_mixer <= music.c
[mips] Compile        : SDL2_mixer <= music_cmd.c
[mips] Compile        : SDL2_mixer <= music_flac.c
[mips] Compile        : SDL2_mixer <= music_fluidsynth.c
[mips] Compile        : SDL2_mixer <= music_mad.c
[mips] Compile        : SDL2_mixer <= music_mikmod.c
[mips] Compile        : SDL2_mixer <= music_modplug.c
[mips] Compile        : SDL2_mixer <= music_mpg123.c
[mips] Compile        : SDL2_mixer <= music_nativemidi.c
[mips] Compile        : SDL2_mixer <= music_ogg.c
[mips] Compile        : SDL2_mixer <= music_smpeg.c
[mips] Compile        : SDL2_mixer <= music_timidity.c
[mips] Compile        : SDL2_mixer <= music_wav.c
[mips] Compile        : mpg123 <= parse.c
[mips] Compile        : mpg123 <= frame.c
[mips] Compile        : mpg123 <= format.c
[mips] Compile        : mpg123 <= dct64.c
[mips] Compile        : mpg123 <= equalizer.c
[mips] Compile        : mpg123 <= id3.c
[mips] Compile        : mpg123 <= optimize.c
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:139:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
enum optdec defdec(void){ return defopt; }
                                 ^~~~~~
                                 getopt
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                if(!auto_choose && want_dec != defopt)
                                               ^~~~~~
                                               getopt
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:31: warning: comparison between pointer and integer ('unsigned int' and 'int (*)(int, char *const *, const char *)')
                if(!auto_choose && want_dec != defopt)
                                   ~~~~~~~~ ^  ~~~~~~
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                        if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                                   ^~~~~~
                                                                                                   getopt
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110
:97: note: expanded from macro 'error2'
#define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                ^
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: warning: format specifies type 'int' but the argument has type 'int (*)(int, char *const *, const char *)' [-Wformat]
                        if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                    ~~             ^~~~~~
/Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
#define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                ^
2 warnings and 3 errors generated.
make: *** [/Users/James/Desktop/test4/app/build/intermediates/ndkBuild/debug/obj/local/mips/objs-debug/mpg123/src/libmpg123/optimize.o] Error 1
:app:externalNativeBuildDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/James/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/James/Desktop/test4/app/jni/Android.mk NDK_APPLICATION_MK=/Users/James/Desktop/test4/app/jni/Application.mk APP_ABI=mips NDK_ALL_ABIS=mips NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=/Users/James/Desktop/test4/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/James/Desktop/test4/app/build/intermediates/ndkBuild/debug/lib APP_PLATFORM=android-14 /Users/James/Desktop/test4/app/build/intermediates/ndkBuild/debug/obj/local/mips/libSDL2_mixer.so}
  [mips] Compile        : SDL2_mixer <= effect_position.c
  [mips] Compile        : SDL2_mixer <= effect_stereoreverse.c
  [mips] Compile        : SDL2_mixer <= effects_internal.c
  [mips] Compile        : SDL2_mixer <= load_aiff.c
  [mips] Compile        : SDL2_mixer <= load_voc.c
  [mips] Compile        : SDL2_mixer <= mixer.c
  [mips] Compile        : SDL2_mixer <= music.c
  [mips] Compile        : SDL2_mixer <= music_cmd.c
  [mips] Compile        : SDL2_mixer <= music_flac.c
  [mips] Compile        : SDL2_mixer <= music_fluidsynth.c
  [mips] Compile        : SDL2_mixer <= music_mad.c
  [mips] Compile        : SDL2_mixer <= music_mikmod.c
  [mips] Compile        : SDL2_mixer <= music_modplug.c
  [mips] Compile        : SDL2_mixer <= music_mpg123.c
  [mips] Compile        : SDL2_mixer <= music_nativemidi.c
  [mips] Compile        : SDL2_mixer <= music_ogg.c
  [mips] Compile        : SDL2_mixer <= music_smpeg.c
  [mips] Compile        : SDL2_mixer <= music_timidity.c
  [mips] Compile        : SDL2_mixer <= music_wav.c
  [mips] Compile        : mpg123 <= parse.c
  [mips] Compile        : mpg123 <= frame.c
  [mips] Compile        : mpg123 <= format.c
  [mips] Compile        : mpg123 <= dct64.c
  [mips] Compile        : mpg123 <= equalizer.c
  [mips] Compile        : mpg123 <= id3.c
  [mips] Compile        : mpg123 <= optimize.c
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:139:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
  enum optdec defdec(void){ return defopt; }
                                   ^~~~~~
                                   getopt
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                  if(!auto_choose && want_dec != defopt)
                                                 ^~~~~~
                                                 getopt
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:31: warning: comparison between pointer and integer ('unsigned int' and 'int (*)(int, char *const *, const char *)')
                  if(!auto_choose && want_dec != defopt)
                                     ~~~~~~~~ ^  ~~~~~~
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                          if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                                     ^~~~~~
                                                                                                     getopt
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
  #define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                  ^
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: warning: format specifies type 'int' but the argument has type 'int (*)(int, char *const *, const char *)' [-Wformat]
                          if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                      ~~             ^~~~~~
  /Users/James/Desktop/test4/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
  #define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                  ^
  2 warnings and 3 errors generated.
  make: *** [/Users/James/Desktop/test4/app/build/intermediates/ndkBuild/debug/obj/local/mips/objs-debug/mpg123/src/libmpg123/optimize.o] Error 1


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

BUILD FAILED

Total time: 5.57 secs

Fixed, thanks!

It now compiles fine and plays mp3 music. Although, when ran on an emulator (tested with Nexus 5X api 24 and Pixel api 26), I get the following popup. I don’t get this popup on an actual device.

Game
Detected problems with app native libraries (please consult log for detail): libmpg123.so: text relocations

The 6th line down of the logcat talks about libmpg123.
The logcat also shows an unrelated bug about swap behavior. Nothing will be drawn to the screen after the app is ran multiple times. I haven’t looked into it too much yet because it only happened on the Nexus 5X emulator and not the Pixel or actual device.

11-06 07:24:44.406 4832-4832/? I/art: Not late-enabling -Xcheck:jni (already on)
11-06 07:24:44.406 4832-4832/? W/art: Unexpected CPU variant for X86 using defaults: x86
11-06 07:24:44.434 4832-4832/com.TestCompany.Test5 V/SDL: Device: generic_x86
11-06 07:24:44.434 4832-4832/com.TestCompany.Test5 V/SDL: Model: Android SDK built for x86
11-06 07:24:44.434 4832-4832/com.TestCompany.Test5 V/SDL: onCreate()
11-06 07:24:44.461 4832-4832/com.TestCompany.Test5 W/linker: /data/app/com.TestCompany.Test5-1/lib/x86/libmpg123.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
11-06 07:24:44.475 4832-4832/com.TestCompany.Test5 V/SDL: nativeSetupJNI()
11-06 07:24:44.475 4832-4832/com.TestCompany.Test5 V/SDL: AUDIO nativeSetupJNI()
11-06 07:24:44.475 4832-4832/com.TestCompany.Test5 V/SDL: CONTROLLER nativeSetupJNI()
11-06 07:24:44.639 4832-4832/com.TestCompany.Test5 V/SDL: onResume()
11-06 07:24:44.819 4832-4847/com.TestCompany.Test5 I/OpenGLRenderer: Initialized EGL, version 1.4
11-06 07:24:44.819 4832-4847/com.TestCompany.Test5 D/OpenGLRenderer: Swap behavior 1
11-06 07:24:44.819 4832-4847/com.TestCompany.Test5 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
11-06 07:24:44.819 4832-4847/com.TestCompany.Test5 D/OpenGLRenderer: Swap behavior 0
11-06 07:24:44.820 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglCreateContext: 0xa9505060: maj 2 min 0 rcv 2
11-06 07:24:44.822 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)
11-06 07:24:44.852 4832-4832/com.TestCompany.Test5 V/SDL: surfaceCreated()
11-06 07:24:44.852 4832-4832/com.TestCompany.Test5 V/SDL: surfaceChanged()
11-06 07:24:44.852 4832-4832/com.TestCompany.Test5 V/SDL: pixel format RGB_565
11-06 07:24:44.852 4832-4832/com.TestCompany.Test5 V/SDL: Window size: 1080x1920
11-06 07:24:44.857 4832-4832/com.TestCompany.Test5 V/SDL: nativeResume()
11-06 07:24:44.858 4832-4848/com.TestCompany.Test5 V/SDL: Running main function SDL_main from library libmain.so
11-06 07:24:44.858 4832-4848/com.TestCompany.Test5 V/SDL: nativeRunMain()
11-06 07:24:44.867 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)
11-06 07:24:44.872 4832-4848/com.TestCompany.Test5 V/SDL: SDL audio: opening device for output
11-06 07:24:44.872 4832-4848/com.TestCompany.Test5 V/SDLAudio: SDL audio: wanted stereo 16-bit 44.1kHz, 4096 frames buffer
11-06 07:24:44.880 4832-4848/com.TestCompany.Test5 D/AudioTrack: Client defaulted notificationFrames to 1365 for frameCount 4096
11-06 07:24:44.880 4832-4848/com.TestCompany.Test5 V/SDLAudio: SDL audio: got stereo 16-bit 44.1kHz, 4096 frames buffer
11-06 07:24:44.902 4832-4848/com.TestCompany.Test5 E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
11-06 07:24:44.909 4832-4848/com.TestCompany.Test5 V/SDL: setOrientation() orientation=-1 width=1080 height=1776 resizable=true hint=
                                                           
                                                           [ 11-06 07:24:44.909  4832: 4848 D/         ]
                                                           HostConnection::get() New Host Connection established 0x9a0c8400, tid 4848
11-06 07:24:44.934 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)
                                                                     
                                                                     [ 11-06 07:24:44.966  4832: 4848 W/         ]
                                                                     Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 
11-06 07:24:44.994 4832-4848/com.TestCompany.Test5 D/EGL_emulation: eglCreateContext: 0x9a0eb560: maj 2 min 0 rcv 2
11-06 07:24:44.995 4832-4848/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0x9a0eb560: ver 2 0 (tinfo 0x9d04fbc0)
11-06 07:24:45.937 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)
11-06 07:24:49.039 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)
11-06 07:24:49.055 4832-4832/com.TestCompany.Test5 V/SDL: onWindowFocusChanged(): true
11-06 07:24:49.071 4832-4847/com.TestCompany.Test5 D/EGL_emulation: eglMakeCurrent: 0xa9505060: ver 2 0 (tinfo 0xa95031d0)

SDL_mixer currently does not build when setting APP_STL to c++_static instead of stlport_static. It did build when I had to completely remove libmpg123 before these recent commits. Libc++ is required for modern c++ and is stated to be the only STL available in the future.
https://developer.android.com/ndk/guides/cpp-support.html

Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/James/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/James/Desktop/testSDLmixer2/app/jni/Android.mk NDK_APPLICATION_MK=/Users/James/Desktop/testSDLmixer2/app/jni/Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=/Users/James/Desktop/testSDLmixer2/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/James/Desktop/testSDLmixer2/app/build/intermediates/ndkBuild/debug/lib APP_PLATFORM=android-14 /Users/James/Desktop/testSDLmixer2/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/libSDL2_mixer.so}
  [armeabi] SharedLibrary  : libSDL2_mixer.so
  /Volumes/Android/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/cxa_handlers.cpp:112: error: undefined reference to '__atomic_exchange_4'
  /Volumes/Android/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/cxa_default_handlers.cpp:109: error: undefined reference to '__atomic_exchange_4'
  /Volumes/Android/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/cxa_default_handlers.cpp:120: error: undefined reference to '__atomic_exchange_4'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [/Users/James/Desktop/testSDLmixer2/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/libSDL2_mixer.so] Error 1

I’m actually not certain when the c++_static began causing the __atomic_exchange_4. I’m getting it an older project now. I have such a difficult time using Android Studio with multiple projects. I feel like they are clashing somehow.

Alright! I figured out why the c++_static __atomic_exchange_4 error seemed intermittent. When I start a new project from SDL with Android Studio 3.0 I get a popup asking to update Android Gradle plugin to version 3.0.0 and Gradle to version 4.1. If I allow it to update the project then I do not get the __atomic_exchange_4 error. Also, after the update Android Studio advises me to update or remove the buildToolsVersion “26.0.1” from the build.gradle.

When I change the compileSdkVersion to 26 and then build a signed release apk, I get the ‘defopt’ errors again.

Executing tasks: [:app:assembleRelease]

Configuration on demand is an incubating feature.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:checkReleaseManifest UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:createReleaseCompatibleScreenManifests UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:splitsDiscoveryTaskRelease UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:javaPreCompileRelease UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:generateJsonModelRelease UP-TO-DATE
:app:externalNativeBuildRelease
Build main x86_64
Android NDK: WARNING: Unsupported source file extensions in /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/Android.mk for module mpg123    
Android NDK:   src/libmpg123/icy.h src/libmpg123/icy2utf8.h src/libmpg123/synth.h src/libmpg123/synth_8bit.h src/libmpg123/dither.h    
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86_64/libmain.so' is up to date.
Build SDL2_mixer x86_64
Android NDK: WARNING: Unsupported source file extensions in /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/Android.mk for module mpg123    
Android NDK:   src/libmpg123/icy.h src/libmpg123/icy2utf8.h src/libmpg123/synth.h src/libmpg123/synth_8bit.h src/libmpg123/dither.h    
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86_64/libSDL2_mixer.so' is up to date.
Build SDL2 x86_64
Android NDK: WARNING: Unsupported source file extensions in /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/Android.mk for module mpg123    
Android NDK:   src/libmpg123/icy.h src/libmpg123/icy2utf8.h src/libmpg123/synth.h src/libmpg123/synth_8bit.h src/libmpg123/dither.h    
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86_64/libSDL2.so' is up to date.
Build mpg123 x86_64
Android NDK: WARNING: Unsupported source file extensions in /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/Android.mk for module mpg123    
Android NDK:   src/libmpg123/icy.h src/libmpg123/icy2utf8.h src/libmpg123/synth.h src/libmpg123/synth_8bit.h src/libmpg123/dither.h    
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86_64/libmpg123.so' is up to date.
Build main x86
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86/libmain.so' is up to date.
Build SDL2_mixer x86
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86/libSDL2_mixer.so' is up to date.
Build mpg123 x86
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86/libmpg123.so' is up to date.
Build SDL2 x86
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/x86/libSDL2.so' is up to date.
Build main mips64
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips64/libmain.so' is up to date.
Build SDL2_mixer mips64
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips64/libSDL2_mixer.so' is up to date.
Build mpg123 mips64
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips64/libmpg123.so' is up to date.
Build SDL2 mips64
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips64/libSDL2.so' is up to date.
Build mpg123 mips
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips/libmpg123.so' is up to date.
Build SDL2 mips
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips/libSDL2.so' is up to date.
Build main mips
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips/libmain.so' is up to date.
Build SDL2_mixer mips
make: `/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/mips/libSDL2_mixer.so' is up to date.
Build main arm64-v8a
[arm64-v8a] Compile        : mpg123 <= optimize.c
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:139:34: error: 
use of undeclared identifier 'defopt'; did you mean 'getopt'?
enum optdec defdec(void){ return defopt; }
                                 ^~~~~~
                                 getopt
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                if(!auto_choose && want_dec != defopt)
                                               ^~~~~~
                                               getopt
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:31: warning: comparison between pointer and integer ('unsigned int' and 'int (*)(int, char *const *, const char *)')
                if(!auto_choose && want_dec != defopt)
                                   ~~~~~~~~ ^  ~~~~~~
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                        if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                                   ^~~~~~
                                                                                                   getopt
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
#define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                ^
/Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
int      getopt(int, char * const [], const char *);
         ^
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: warning: format specifies type 'int' but the argument has type 'int (*)(int, char *const *, const char *)' [-Wformat]
                        if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                    ~~             ^~~~~~
/Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
#define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                ^
2 warnings and 3 errors generated.
make: *** [/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/arm64-v8a/objs/mpg123/src/libmpg123/optimize.o] Error 1
:app:externalNativeBuildRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process /Users/James/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/James/Desktop/testSDLmixer/app/jni/Android.mk NDK_APPLICATION_MK=/Users/James/Desktop/testSDLmixer/app/jni/Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=0 APP_PLATFORM=android-21 NDK_OUT=/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/lib APP_PLATFORM=android-14 /Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/arm64-v8a/libmain.so}
  [arm64-v8a] Compile        : mpg123 <= optimize.c
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:139:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
  enum optdec defdec(void){ return defopt; }
                                   ^~~~~~
                                   getopt
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:34: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                  if(!auto_choose && want_dec != defopt)
                                                 ^~~~~~
                                                 getopt
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:513:31: warning: comparison between pointer and integer ('unsigned int' and 'int (*)(int, char *const *, const char *)')
                  if(!auto_choose && want_dec != defopt)
                                     ~~~~~~~~ ^  ~~~~~~
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: error: use of undeclared identifier 'defopt'; did you mean 'getopt'?
                          if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                                     ^~~~~~
                                                                                                     getopt
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
  #define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                  ^
  /Users/James/Library/Android/sdk/ndk-bundle/sysroot/usr/include/bits/getopt.h:36:6: note: 'getopt' declared here
  int      getopt(int, char * const [], const char *);
           ^
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/optimize.c:515:79: warning: format specifies type 'int' but the argument has type 'int (*)(int, char *const *, const char *)' [-Wformat]
                          if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
                                                                                      ~~             ^~~~~~
  /Users/James/Desktop/testSDLmixer/app/jni/SDL_mixer/external/mpg123-1.25.6/src/libmpg123/debug.h:110:97: note: expanded from macro 'error2'
  #define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
                                                                                                  ^
  2 warnings and 3 errors generated.
  make: *** [/Users/James/Desktop/testSDLmixer/app/build/intermediates/ndkBuild/release/obj/local/arm64-v8a/objs/mpg123/src/libmpg123/optimize.o] Error 1


* 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 4s

16 actionable tasks: 1 executed, 15 up-to-date

Is there a chance that ‘defopt’ errors will be fixed?

Yes, this is fixed in Mercurial:

In general bugs should be reported in bugzilla so you get notifications of fixes, and so they don’t get lost.

I got ‘defopt’ errors when I click “Build” in Android studio. But when I click “Run” in android studio I got “Warning: shared library text segment is not shareable” - this is for android x86. I will create bug report in bugzilla.