saber-notes / saber

The cross-platform open-source app built for handwriting
https://saber.adil.hanney.org
GNU General Public License v3.0
2.05k stars 125 forks source link

[onyxsdk_pen] The file was not recognized as a valid object file #890

Open sarbogast opened 1 year ago

sarbogast commented 1 year ago

Describe the bug

When I try to build my project with the latest version of Flutter (3.13.0), I get the following compilation errors:

Running Gradle task 'assembleDevDebug'...
Note: /Users/sarbogast/.pub-cache/hosted/pub.dev/cloud_firestore-4.9.0/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestoreMessageCodec.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/scorelyr/scorelyr/build/app/intermediates/merged_native_libs/devDebug/out/lib/armeabi-v7a/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/scorelyr/scorelyr/build/app/intermediates/merged_native_libs/devDebug/out/lib/arm64-v8a/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/scorelyr/scorelyr/build/app/intermediates/merged_native_libs/devDebug/out/lib/x86/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: program header with offset 0x2f2c70 and file size 0x1390 goes past the end of the file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/scorelyr/scorelyr/build/app/intermediates/merged_native_libs/devDebug/out/lib/x86_64/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/dev/scorelyr/scorelyr/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:104: error: cannot find symbol
      flutterEngine.getPlugins().add(new com.example.onyxsdk_pen.OnyxsdkPenPlugin());
                                                                ^
  symbol:   class OnyxsdkPenPlugin
  location: package com.example.onyxsdk_pen
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDevDebugJavaWithJavac'.
> 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 46s
Exception: Gradle task assembleDevDebug failed with exit code 1

Any idea why?

To reproduce

Build the example project targetting an Onyx device and you will see those same errors.

Expected behavior

No errors

Saber version

onyxsdk_pen 1.1.0

Device

Anything else?

No response

adil192 commented 1 year ago

I can't reproduce this error when running flutter build apk in the example directory:

adilh@DESKTOP-M5JKVNO MINGW64 ~/Documents/GitHub/saber/packages/onyxsdk_pen/example (main)
$ flutter build apk

Upgrading build.gradle
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Running Gradle task 'assembleRelease'...                          243.3s
✓  Built build\app\outputs\flutter-apk\app-release.apk (55.3MB).

Please can you share the ouput of flutter doctor -v and flutter build apk in the example directory.

sarbogast commented 1 year ago
sarbogast@MacBook-Pro-51 example % flutter doctor -v
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.4.1 22F770820d darwin-arm64, locale en-FR)
    • Flutter version 3.13.0 on channel stable at /Users/sarbogast/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (10 days ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/sarbogast/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2022.3)
    • 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.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/sarbogast/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.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.1)
    • IntelliJ at /Users/sarbogast/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.1)
    • IntelliJ at /Users/sarbogast/Applications/IntelliJ IDEA Ultimate 2023.2.1.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

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

[✓] Connected device (6 available)
    • NovaAir2 (mobile)                   • 6580CCCE                             • android-arm64  • Android 11 (API 30)
    • sdk gphone arm64 (mobile)           • emulator-5554                        • android-arm64  • Android 11 (API 30) (emulator)
    • iPhone de Sebastien (mobile)        • 00008110-001578EA0182801E            • ios            • iOS 16.6 20G75
    • iPhone SE (3rd generation) (mobile) • 47466750-B63C-4329-B4DC-0AE9ED3EB5C3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)                     • macos                                • darwin-arm64   • macOS 13.4.1 22F770820d darwin-arm64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 116.0.5845.110
    ! Error: (null) needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the
      iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1)

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

• No issues found!
sarbogast@MacBook-Pro-51 example % flutter build apk

Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/armeabi-v7a/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: program header with offset 0x2f2c70 and file size 0x1390 goes past the end of the file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/x86/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/arm64-v8a/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/x86_64/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/armeabi-v7a/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy: error: program header with offset 0x2f2c70 and file size 0x1390 goes past the end of the file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/x86_64/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/x86/libc++.so': The file was not recognized as a valid object file

/Users/sarbogast/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy: error: '/Users/sarbogast/dev/saber/packages/onyxsdk_pen/example/build/app/intermediates/merged_native_libs/release/out/lib/arm64-v8a/libc++.so': The file was not recognized as a valid object file

Running Gradle task 'assembleRelease'...                           46.3s
✓  Built build/app/outputs/flutter-apk/app-release.apk (55.3MB).
adil192 commented 1 year ago

Is your app able to build if you remove the onyxsdk_pen package? Also, can you confirm you followed the Getting Started instructions?

sarbogast commented 1 year ago

Yes, and yes

adil192 commented 1 year ago

Please can you try this solution (from https://stackoverflow.com/a/74776512):

flutter clean
flutter pub cache repair
flutter pub get

or if that doesn't work, try updating your sdkVersions like in https://stackoverflow.com/a/75579610 (not necessarily to these values, they're just an example):

// android/app/build.gradle

    android {
        compileSdkVersion 33  //was => flutter.compileSdkVersion  
    }

    defaultConfig {
        minSdkVersion 29 // was => flutter.minSdkVersion
        targetSdkVersion 33 // was => flutter.targetSdkVersion
    }

If the second solution is what fixes this, I'll need to update the Getting Started instructions.