Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11

I recently encountered an issue in ReactExoplayerView where playback speed adjustments weren’t working as expected. Here’s the fix that resolved the problem:

Original Code (Using a Switch Expression):

float speed = switch (which) {
c…


This content originally appeared on DEV Community and was authored by Ajmal Hasan

I recently encountered an issue in ReactExoplayerView where playback speed adjustments weren't working as expected. Here's the fix that resolved the problem:

Original Code (Using a Switch Expression):

float speed = switch (which) {
    case 0 -> 0.5f;
    case 2 -> 1.5f;
    case 3 -> 2.0f;
    default -> 1.0f;
};

Updated Code (Using a Traditional Switch Statement):

switch (which) {
    case 0:
        speed = 0.5f;
        break;
    case 2:
        speed = 1.5f;
        break;
    case 3:
        speed = 2.0f;
        break;
    default:
        speed = 1.0f;
        break;
}

The issue was caused by the switch expression, which I replaced with a traditional switch statement. After making this change, the playback speeds worked correctly.

Final Step:

After making the code change, I used patch-package to ensure the fix was preserved:

npx patch-package react-native-video

This fixed the bug and ensured smooth playback speed transitions in my React Native app.


This content originally appeared on DEV Community and was authored by Ajmal Hasan


Print Share Comment Cite Upload Translate Updates
APA

Ajmal Hasan | Sciencx (2024-10-26T20:09:28+00:00) Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11. Retrieved from https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/

MLA
" » Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11." Ajmal Hasan | Sciencx - Saturday October 26, 2024, https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/
HARVARD
Ajmal Hasan | Sciencx Saturday October 26, 2024 » Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11., viewed ,<https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/>
VANCOUVER
Ajmal Hasan | Sciencx - » Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/
CHICAGO
" » Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11." Ajmal Hasan | Sciencx - Accessed . https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/
IEEE
" » Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11." Ajmal Hasan | Sciencx [Online]. Available: https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/. [Accessed: ]
rf:citation
» Solution: compileDebugJavaWithJavac because error: switch expressions are not supported in -source 11 | Ajmal Hasan | Sciencx | https://www.scien.cx/2024/10/26/solution-compiledebugjavawithjavac-because-error-switch-expressions-are-not-supported-in-source-11/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.