ryanheise / audio_session

MIT License
107 stars 68 forks source link

Can't build on android when targetting android 34 #108

Closed Tom3652 closed 7 months ago

Tom3652 commented 9 months ago

Thanks for your package !

I have tried to build my app and set targetSdkVersion 34 for each of my sub-projects but it doesn't work and give the following output when failing on yours :

/Users/foxtom/.pub-cache/hosted/pub.dev/audio_session-0.1.16/android/src/main/java/com/ryanheise/audio_session/AndroidAudioManager.java:448: warning: [deprecation] setSpeakerphoneOn(boolean) in AudioManager has been deprecated
            audioManager.setSpeakerphoneOn(enabled);
                        ^
/Users/foxtom/.pub-cache/hosted/pub.dev/audio_session-0.1.16/android/src/main/java/com/ryanheise/audio_session/AndroidAudioManager.java:452: warning: [deprecation] isSpeakerphoneOn() in AudioManager has been deprecated
            return audioManager.isSpeakerphoneOn();
                               ^
/Users/foxtom/.pub-cache/hosted/pub.dev/audio_session-0.1.16/android/src/main/java/com/ryanheise/audio_session/AndroidAudioManager.java:467: warning: [deprecation] startBluetoothSco() in AudioManager has been deprecated
            audioManager.startBluetoothSco();
                        ^
/Users/foxtom/.pub-cache/hosted/pub.dev/audio_session-0.1.16/android/src/main/java/com/ryanheise/audio_session/AndroidAudioManager.java:471: warning: [deprecation] stopBluetoothSco() in AudioManager has been deprecated
            audioManager.stopBluetoothSco();
                        ^
/Users/foxtom/.pub-cache/hosted/pub.dev/audio_session-0.1.16/android/src/main/java/com/ryanheise/audio_session/AndroidAudioManager.java:479: warning: [deprecation] isBluetoothScoOn() in AudioManager has been deprecated
            return audioManager.isBluetoothScoOn();
                               ^
error: warnings found and -Werror specified
1 error
5 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':audio_session: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.
> Run with --scan to get full insights.

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

BUILD FAILED in 1m 11s
Exception: Gradle task assembleDebug failed with exit code 1

Note : this is not blocking to build the app, i simply set to 33 and it works fine

ryanheise commented 9 months ago

Thanks for the report. I see the 5 warnings above, but what was the 1 error?

ryanheise commented 9 months ago

Ah, that's just my build flag to force an error if there are any warnings. It was intended to help me catch problems sooner, so I guess it is doing its job.

It looks like some methods were deprecated in API level 34, so it'll need to be updated to deal with the new APIs intended to replace those.

Tom3652 commented 9 months ago

I think this is due to : -Werror specified what do you think ?

Edit : Thanks for your reactivity and work, i see you got it too !

jonmountjoy commented 9 months ago

Can anyone recommend a way for me to get around this?

When I do a flutter build apk it all works fine, but I'm trying to generate some test assets using ./gradlew app:assembleAndroidTest and then it fails with:

> Task :just_audio:compileDebugJavaWithJavac FAILED
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
error: warnings found and -Werror specified

FAILURE: Build failed with an exception.

I've tried adding --warning-mode=none to the ./gradlew but that didn't seem to do anything. I've also tried editing ./pub-cache/hosted/pub.dev/audio_session-0.1.16/android/build.gradle and removing the -Werror but somehow the problem persists (I guess it's cached somewhere?)

Any pointers appreciated!

PS. I'm using compileSdkVersion 33 and

classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15
ryanheise commented 9 months ago

You can clone the git repo and edit the build.gradle, then update your pubspec to point to your version of the plugin. You might need a dependency override (in pubspec) to force just_audio to use your version of it.

ryanheise commented 7 months ago

I've published version 0.1.17 which suppresses the deprecation warnings for these 5 method calls, so this should allow it to compile.

The new APIs Android introduced to replace the old APIs have not been implemented, but that can be saved for a future effort.

Thanks @Tom3652 for reporting.

I'll close the issue but let me know if the release doesn't work and I'll be happy to reopen the issue.

knightowlRaising commented 6 months ago

` FAILURE: Build failed with an exception.

Still getting this error

Murtaza-Tn commented 6 months ago

FAILURE: Build failed with an exception.

I'm facing the same problem. compileSdkVersion 33 minSdkVersion 21 targetSdkVersion 33

ryanheise commented 6 months ago

This does not appear to be the same issue since it is about targeting SDK 34, and the error message is also different. The original error very specifically identified the use of methods that were deprecated in SDK 34. Unless I'm mistaken about what I just said, can you please open a new issue with the details of how I can reproduce this and an exact copy of the full error output?