Skip to content

[camera][android] Unit tests fail #71709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
svenjacobs opened this issue Dec 4, 2020 · 5 comments
Closed

[camera][android] Unit tests fail #71709

svenjacobs opened this issue Dec 4, 2020 · 5 comments
Labels
c: crash Stack traces logged to the console found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: camera The camera plugin package flutter/packages repository. See also p: labels.

Comments

@svenjacobs
Copy link

svenjacobs commented Dec 4, 2020

I'm integrating a Flutter module into an Android app in an "add 2 app" situation. After adding camera (0.5.8+11) to the Flutter module, the Android unit tests fail. When running ./gradlew test in my Android project I get the following error:

> Task :camera:compileDebugUnitTestJavaWithJavac FAILED
/Users/sven/.pub-cache/hosted/pub.dartlang.org/camera-0.5.8+11/android/src/test/java/io/flutter/plugins/camera/DartMessengerTest.java:103: warning: [unchecked] unchecked cast
        return (Map<String, String>) StandardMethodCodec.INSTANCE.decodeEnvelope(sentMessage);
                                                                                ^
  required: Map<String,String>
  found:    Object
error: warnings found and -Werror specified
1 error
1 warning

I'm wondering how this failing unit test was not discovered yet because the unchecked cast is ignored in the test's source code but obviously warnings are treated as errors.

Flutter version 1.22.4.

@TahaTesser
Copy link
Member

TahaTesser commented Dec 4, 2020

Hi @svenjacobs
Can you please provide your flutter doctor -v and a complete reproducible minimal code sample in a GitHub repository including sample module and sample android app?
Thank you

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Dec 4, 2020
@svenjacobs
Copy link
Author

Output of flutter doctor -v:

[✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-DE)
    • Flutter version 1.22.4 at /Users/sven/.fvm/versions/stable
    • Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/sven/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_SDK_ROOT = /Users/sven/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.10.0

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin installed
    • Dart plugin version 203.5981.152

[✓] VS Code (version 1.51.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (1 available)
    • Pixel (mobile) • FA69L0316725 • android-arm64 • Android 10 (API 29)

! Doctor found issues in 1 category.

(by the way, the warning is wrong. Flutter & Dart plugins are installed in Android Studio)

The example project can be found here. Please run ./gradlew test in android folder.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 4, 2020
@TahaTesser
Copy link
Member

Hi @svenjacobs
I can reproduce the issue, thanks for filing the issue

logs
PS C:\Users\Taha> cd C:\Users\Taha\AndroidStudioProjects\flutter-camera-issue-71709\flutter\.android
PS C:\Users\Taha\AndroidStudioProjects\flutter-camera-issue-71709\flutter\.android> ./gradlew test

Welcome to Gradle 5.6.2!

Here are the highlights of this release:
 - Incremental Groovy compilation
 - Groovy compile avoidance
 - Test fixtures for Java projects
 - Manage plugin versions via settings script

For more details see https://docs.gradle.org/5.6.2/release-notes.html


> Task :camera:compileDebugUnitTestJavaWithJavac FAILED
C:\Users\Taha\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\camera-0.5.8+17\android\src\test\java\io\flutter\plugins\camera\DartMessengerTest.java:99: warning: [unchecked] unchecked cast
    return (Map<String, String>) StandardMethodCodec.INSTANCE.decodeEnvelope(sentMessage);
                                                                            ^
  required: Map<String,String>
  found:    Object
error: warnings found and -Werror specified
1 error
1 warning

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':camera:compileDebugUnitTestJavaWithJavac'.
> 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 10s
115 actionable tasks: 85 executed, 30 up-to-date
PS C:\Users\Taha\AndroidStudioProjects\flutter-camera-issue-71709\flutter\.android>
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.630], locale en-US)
    • Flutter version 1.22.4 at C:\Code\flutter_stable
    • Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Code\sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = C:\Code\sdk
    • Java binary at: C:\Code\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (version 4.1.0)
    • Android Studio at C:\Code\android-studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] VS Code (version 1.51.1)
    • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.17.0

[✓] Connected device (1 available)
    • sdk gphone x86 (mobile) • emulator-5556 • android-x86 • Android 11 (API 30) (emulator)

! Doctor found issues in 1 category.

@TahaTesser TahaTesser added found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: camera The camera plugin p: first party c: crash Stack traces logged to the console and removed in triage Presently being triaged by the triage team labels Dec 7, 2020
@mvanbeusekom
Copy link

Fixed with PR flutter/plugins#3316.

@github-actions
Copy link

github-actions bot commented Aug 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: camera The camera plugin package flutter/packages repository. See also p: labels.
Projects
None yet
Development

No branches or pull requests

3 participants