plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: flutter run error from

Open madmanleaf opened this issue 6 months ago • 8 comments

Platform

Android 15

Plugin

package_info_plus

Version

8.0.1

Flutter SDK

3.24.0-0.2.pre

Steps to reproduce

Unless it is not applicable, the error is always reported

Code Sample

import 'dart:ui';
import 'package:get/get.dart';
// import 'package:package_info_plus/package_info_plus.dart';
import '../index.dart';

/// 配置服务
class ConfigService extends GetxService {
  static ConfigService get to => Get.find();
  final Rx<Locale> _locale = PlatformDispatcher.instance.locale.obs;
  Locale get locale => _locale.value;
  // PackageInfo? _platform;
  // String get version => _platform?.version ?? '-';

  // 主题
  final RxBool _isDarkModel = Get.isDarkMode.obs;
  bool get isDarkModel => _isDarkModel.value;

  // 是否首次打开
  bool get isAlreadyOpen => Storage().getBool(Constants.storageAlreadyOpen);

  @override
  void onReady() {
    super.onReady();
    // getPlatform();
    initLocale();
    initTheme();
  }

  // 标记已打开app
  void setAlreadyOpen() {
    Storage().setBool(Constants.storageAlreadyOpen, true);
  }

  // Future<void> getPlatform() async {
  //   _platform = await PackageInfo.fromPlatform();
  // }
  // 切换 theme主题
  Future<void> switchThemeModel() async {
    _isDarkModel.value = !_isDarkModel.value;
    Get.changeTheme(
      _isDarkModel.value == true ? AppTheme.dark : AppTheme.light,
    );
    await Storage().setString(Constants.storageThemeCode,
        _isDarkModel.value == true ? "dark" : "light");
  }

  // 初始 theme主题
  void initTheme() {
    var themeCode = Storage().getString(Constants.storageThemeCode);
    _isDarkModel.value = themeCode == "dark" ? true : false;
    Get.changeTheme(
      themeCode == "dark" ? AppTheme.dark : AppTheme.light,
    );
  }

  // 初始语言
  void initLocale() {
    var langCode = Storage().getString(Constants.storageLanguageCode);
    if (langCode.isEmpty) return;
    var index = Translation.supportedLocales.indexWhere((element) {
      return element.languageCode == langCode;
    });
    if (index < 0) return;
    _locale.value = Translation.supportedLocales[index];
  }

  // 更新语言
  void updateLanguage(Locale newLocale) {
    _locale.value = newLocale;
    Storage().setString(Constants.storageLanguageCode, newLocale.languageCode);
    Get.updateLocale(newLocale);
  }

}

Logs

[        ] FAILURE: Build failed with an exception.
[        ] * What went wrong:
[        ] Execution failed for task ':package_info_plus:compileDebugJavaWithJavac'.
[        ] > Could not resolve all files for configuration ':package_info_plus:androidJdkImage'.
[        ]    > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
[        ]       > Execution failed for JdkImageTransform: C:\Users\madma\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar.
[        ]          > Error while executing process D:\Program\JetBrains\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\madma\.gradle\caches\8.9\transforms\15cf82747c839484d9461063b2aa76df-bec856da-5605-4eea-9f72-2b794a79b08f\transformed\output\temp\jmod --add-modules java.base --output C:\Users\madma\.gradle\caches\8.9\transforms\15cf82747c839484d9461063b2aa76df-bec856da-5605-4eea-9f72-2b794a79b08f\transformed\output\jdkImage --disable-plugin system-modules}
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] > Get more help at https://help.gradle.org.

Flutter Doctor

PS C:\Users\madma> flutter doctor -v
[✓] Flutter (Channel beta, 3.24.0-0.2.pre, on Microsoft Windows [版本 10.0.26120.1330], locale zh-CN)
    • Flutter version 3.24.0-0.2.pre on channel beta at D:\code\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7c6b7e9ca4 (4 days ago), 2024-07-30 14:26:44 +0700
    • Engine revision 6e4deceb38
    • Dart version 3.5.0 (build 3.5.0-323.2.beta)
    • DevTools version 2.37.2

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\madma\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = C:\Users\madma\AppData\Local\Android\Sdk
    • Java binary at: D:\Program\JetBrains\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12099254-b509.4)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/windows-android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.8.0 Preview 1.0)
    • Visual Studio at D:\Program Files\Microsoft Visual Studio\2022\Preview
    • Visual Studio Enterprise 2022 version 17.8.34004.107
    • The current Visual Studio installation is a pre-release version. It may not be supported by Flutter yet.
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2024.1)
    • Android Studio at D:\Program\JetBrains\Android Studio 2
    • 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.10+0--11609105)

[✓] Android Studio (version 2024.2)
    • Android Studio at D:\Program\JetBrains\Android Studio
    • 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 21.0.3+-12099254-b509.4)

[✓] VS Code, 64-bit edition (version unknown)
    • VS Code at C:\Program Files\Microsoft VS Code Insiders
    • Flutter extension version 3.93.20240702
    ✗ Unable to determine VS Code version.

[✓] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 15 (API 35) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [版本 10.0.26120.1330]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 127.0.6533.89
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 128.0.2739.5

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

! Doctor found issues in 1 category.

Checklist before submitting a bug

  • [X] I searched issues in this repository and couldn't find such bug/problem
  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

madmanleaf avatar Aug 03 '24 12:08 madmanleaf