thingsboard / flutter_thingsboard_app

ThingsBoard Mobile Application
https://thingsboard.io/products/mobile/
BSD 3-Clause "New" or "Revised" License
226 stars 167 forks source link

Can't build the flutter application. #157

Open Vaibhav0216 opened 3 days ago

Vaibhav0216 commented 3 days ago

I follow the documentation of the thingsboard mobile development.

Below error comes on flutter run...

PS C:\Users\Admin\Desktop\flutter_thingsboard_app> flutter run "ar": 73 untranslated message(s). "zh": 92 untranslated message(s). "zh_CN": 92 untranslated message(s). "zh_TW": 91 untranslated message(s). To see a detailed report, use the untranslated-messages-file option in the l10n.yaml file: untranslated-messages-file: desiredFileName.txt

: This will generate a JSON format file containing all messages that need to be translated. Launching lib\main.dart on SM A707F in debug mode... FAILURE: Build completed with 2 failures. 1: Task failed with an exception. ----------- * Where: Build file 'C:\Users\Admin\Desktop\flutter_thingsboard_app\android\build.gradle' line: 14 * What went wrong: A problem occurred evaluating root project 'android'. > A problem occurred configuring project ':app'. > Could not create task ':app:copyFlutterAssetsDebug'. > Could not create task ':app:mergeDebugAssets'. * 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. ============================================================================== 2: Task failed with an exception. ----------- * Where: Build file 'C:\Users\Admin\Desktop\flutter_thingsboard_app\android\build.gradle' line: 14 * What went wrong: A problem occurred evaluating root project 'android'. > A problem occurred configuring project ':app'. > Could not create task ':app:copyFlutterAssetsDebug'. > Could not create task ':app:mergeDebugAssets'. > Cannot use @TaskAction annotation on method IncrementalTask.taskAction$gradle_core() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method. * 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 1s Running Gradle task 'assembleDebug'... 2,666ms Error: Gradle task assembleDebug failed with exit code 1 PS C:\Users\Admin\Desktop\flutter_thingsboard_app>
ybeshkarov commented 1 day ago

Hi,

Please check if this response will help you resolve the issue https://github.com/thingsboard/flutter_thingsboard_pe_app/issues/194#issuecomment-2489107289

Vaibhav0216 commented 1 day ago

But I am using jdk-17 version and i also tried,

C:\Users\Admin>fvm flutter config --jdk-dir "C:\Program Files\Java\jdk-17"
Setting "jdk-dir" value to "C:\Program Files\Java\jdk-17".

You may need to restart any open editors for them to read new settings.

But still error not gone.

My java version

C:\Users\Admin>java --version
java 17.0.13 2024-10-15 LTS
Java(TM) SE Runtime Environment (build 17.0.13+10-LTS-268)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.13+10-LTS-268, mixed mode, sharing)
ybeshkarov commented 21 hours ago

Can you provide details about your environment?

Vaibhav0216 commented 7 hours ago

@ybeshkarov thank you for helping. flutter version -> 3.24.5 IDE -> vscode mobile app version ->1.4.0

C:\Users\Admin>flutter --version
Flutter 3.24.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision dec2ee5c1f (8 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3

my pubspec.yaml

name: thingsboard_app
description: Flutter ThingsBoard Mobile Application

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.4.0

environment:
  sdk: ">=3.2.0 <4.0.0"

dependencies:
  flutter:
    sdk: flutter
  thingsboard_client: ^2.0.0
  mockito: ^5.0.0
  intl: ^0.19.0
  flutter_secure_storage: ^9.0.0
  flutter_speed_dial: ^7.0.0
  cupertino_icons: ^1.0.6
  fluro: ^2.0.5
  flutter_svg: ^2.0.9
  jovial_svg: ^1.1.19
  auto_size_text: ^3.0.0-nullsafety.0
  infinite_scroll_pagination: ^4.0.0
  fading_edge_scrollview: ^4.0.0
  stream_transform: ^2.1.0
  flutter_inappwebview: ^6.1.5
  url_launcher: ^6.2.1
  image_picker: ^1.0.4
  mime: ^2.0.0
  logger: ^2.0.2+1
  qr_code_scanner: ^1.0.1
  device_info_plus: ^11.1.1
  geolocator: ^13.0.2
  material_design_icons_flutter: ^7.0.7296
  package_info_plus: ^8.0.0
  dart_jsonwebtoken: ^2.12.1
  crypto: ^3.0.3
  flutter_form_builder: ^9.1.1
  form_builder_validators: ^11.0.0
  flutter_html: 3.0.0-beta.2
  universal_html: ^2.2.4
  universal_platform: ^1.0.0+1
  preload_page_view: ^0.2.0
  flutter_localizations:
    sdk: flutter
  firebase_core: ^3.1.0
  firebase_messaging: ^15.0.1
  flutter_local_notifications: ^18.0.1
  flutter_app_badger: ^1.5.0
  timeago: ^3.6.1
  flutter_slidable: ^3.0.1
  flutter_bloc: ^8.1.5
  get_it: ^8.0.2
  equatable: ^2.0.5
  uni_links: ^0.5.1
  collection: ^1.18.0
  html: ^0.15.4
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  modal_bottom_sheet: ^3.0.0
  event_bus: ^2.0.0
  google_fonts: ^6.2.1
  expandable: ^5.0.1
  focused_menu: ^1.0.5

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.14.1
  mocktail: ^1.0.3
  bloc_test: ^9.1.7
  flutter_lints: ^5.0.0
  hive_generator: ^2.0.1
  build_runner: ^2.4.9

flutter:
  uses-material-design: true
  assets:
     - assets/images/
  generate: true

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

flutter_icons:
  android: "launcher_icon"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/images/thingsboard.png"
flutter_intl:
  enabled: true
Vaibhav0216 commented 6 hours ago

I have cloned repository again and executed following commands :- 1) flutter doctor ( No issue arise ) 2) flutter pub get 3) flutter build apk

Then error comes 1) A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action -> To resolve this I have increase memory for JVM ( org.gradle.jvmargs=-Xmx4608m ) 2) Warning: This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
-> above warning and error comes

PS C:\Users\Admin\Desktop\F_app> flutter build apk 

Warning: This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.     
Font asset "materialdesignicons-webfont.ttf" was tree-shaken, reducing it from 1279992 to 1034252 bytes (19.2% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 279684 bytes (83.0% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':flutter_app_badger:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:C:\Users\Admin\Desktop\F_app\build\flutter_app_badger\intermediates\merged_res\release\values\values.xml:194: AAPT: error: resource android:attr/lStar not found.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 31s
Running Gradle task 'assembleRelease'...                           32.3s
Gradle task assembleRelease failed with exit code 1
ybeshkarov commented 2 hours ago

Regarding the Java version, I see you're using fvm to set fvm flutter config

but for building, you're using the globally installed Flutter flutter build apk

Try to set Java for the globally installed Flutter as well flutter config --jdk-dir "C:\Program Files\Java\jdk-17"