Skip to content
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

[ERROR] Sentry Example-App not building with latest Flutter Beta #2381

Open
martinhaintz opened this issue Oct 30, 2024 · 8 comments · Fixed by #2385 · May be fixed by #2407
Open

[ERROR] Sentry Example-App not building with latest Flutter Beta #2381

martinhaintz opened this issue Oct 30, 2024 · 8 comments · Fixed by #2385 · May be fixed by #2407
Assignees

Comments

@martinhaintz
Copy link
Collaborator

Platform

Flutter Mobile

Obfuscation

Disabled

Debug Info

Disabled

Doctor

[✓] Flutter (Channel beta, 3.27.0-0.1.pre, on macOS 14.6.1 23G93 darwin-arm64, locale en-AT)
    • Flutter version 3.27.0-0.1.pre on channel beta at /Users/martin/fvm/versions/3.27.0-0.1.pre
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2e2c358c9b (8 days ago), 2024-10-22 11:02:13 -0400
    • Engine revision af0f0d559c
    • Dart version 3.6.0 (build 3.6.0-334.3.beta)
    • DevTools version 2.40.1

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/martin/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

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

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 130.0.6723.70

[✓] Network resources
    • All expected network resources are available.

Version

latest main branch

Steps to Reproduce

Use the current Flutter Beta (3.27.0-0.1.pre) and try to build the sentry example app with flutter build apk --debug

Expected Result

Successful build.

Actual Result

#: flutter build apk --debug
Changing current working directory to: /Users/martin/Repositories/sentry-dart/flutter/example

You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

 android plugin version 8.3.2
:app:external cmake build 

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/martin/Repositories/sentry-dart/flutter/example/android/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:releaseCompileClasspath'.
      > Could not find io.flutter:x86_release:1.0.0-af0f0d559c8a87d912a20971bbd84afc80a54b0f.
        Required by:
            project :app

* 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 3s
Running Gradle task 'assembleDebug'...                              3.8s
Gradle task assembleDebug failed with exit code 1

Are you willing to submit a PR?

Yes

@martinhaintz
Copy link
Collaborator Author

I was able to nail it down to the androidNativeBundle.

After removing the following lines:
android/build.gradle
classpath 'io.github.howardpang:androidNativeBundle:1.1.4'

app/build.gradle
apply plugin: 'com.ydq.android.gradle.native-aar.import'

externalNativeBuild {
    cmake {
        arguments.add(0, "-DANDROID_STL=c++_static")
    }
}

ndk {
    // Flutter does not currently support building for x86 Android (See Issue 9253).
    abiFilters("armeabi-v7a", "x86_64", "arm64-v8a")
}
externalNativeBuild {
    cmake {
        setPath("CMakeLists.txt")
    }
}

I was able to build the example app with fvm flutter build apk --debug again.

@martinhaintz
Copy link
Collaborator Author

martinhaintz commented Nov 4, 2024

@romtsn found the reason. In the latest commit from Oct 1st, they included the x86 platform by default for debug builds.

Appending --target-platform=android-64 will resolve this error.

I also left a comment on the Flutter PR asking the developer if this decision was intentional or by accident.

@martinhaintz
Copy link
Collaborator Author

As written here, we should further investigate and check our gradle config for potential errors.

@martinhaintz
Copy link
Collaborator Author

I forgot to remove the close #2381 statement, so I reopened the issue. We should investigate this problem further.

@buenaflor
Copy link
Contributor

buenaflor commented Nov 7, 2024

generally I'm not sure if spending more time on debugging this makes sense

We figured out the culprit and found a workaround that works. In the end it's only our example app and doesn't affect real users at all.

What we should investigate is if we still need this plugin - are there alternatives? as far as I can tell we need it for our NDK example

@martinhaintz
Copy link
Collaborator Author

Based on the responses to my comment in the flutter gradle change and the issue I created in the androidNativeBundle, it looks like it is a bug in the androidNativeBundle which came up with the recent flutter gradle changes.

The maintainer of the androidNativeBundle plans to adapt the plugin.

It's up to you @buenaflor, to decide, if we should leave this issue open, and come back, when the androidNativeBundle is updated, and revert the changes, or if we can leave everything as it is now, because we only want to test the build, which is now possible?

Regarding your question about the need of this plugin. As far as I can tell we don't have to use this plugin, but it makes handling native code very convenient. I also cannot say, if there are suitable alternatives for this plugin.
Maybe @romtsn is more familiar, with gradle and android native plugins and can answer this questions?

@buenaflor
Copy link
Contributor

buenaflor commented Nov 11, 2024

if the maintainer fixes it then it's fine for me to leave this open and wait for his fix

@buenaflor buenaflor moved this from Done to Blocked in Mobile & Cross Platform SDK Nov 11, 2024
@buenaflor
Copy link
Contributor

Waiting for howardpang/androidNativeBundle#20 to be fixed

@martinhaintz martinhaintz linked a pull request Nov 12, 2024 that will close this issue
6 tasks
@martinhaintz martinhaintz self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Blocked
2 participants