java - "error: cannot find symbol"在 flutter 中为 Android 构建时

标签 java android flutter kotlin

尝试在我的 flutter 应用程序中为 android 构建时,我不断收到此错误。这一切都是在我添加 firebase messaging version 7.0.3 时发生的.即使在删除它之后,我仍然存在这个问题。

/Users/bright/Desktop/flutter_apps/rush_user_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:20: error: cannot find symbol
    flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin());
                                                                                          ^
  symbol:   class FlutterAndroidLifecyclePlugin                         
  location: package io.flutter.plugins.flutter_plugin_android_lifecycle 
/Users/bright/Desktop/flutter_apps/rush_user_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:24: error: cannot find symbol
    flutterEngine.getPlugins().add(new io.flutter.plugins.googlemaps.GoogleMapsPlugin());
                                                                    ^   
  symbol:   class GoogleMapsPlugin                                      
  location: package io.flutter.plugins.googlemaps                       
/Users/bright/Desktop/flutter_apps/rush_user_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:25: error: cannot find symbol
    flutterEngine.getPlugins().add(new io.flutter.plugins.googlesignin.GoogleSignInPlugin());
                                                                      ^ 
  symbol:   class GoogleSignInPlugin                                    
  location: package io.flutter.plugins.googlesignin                     
/Users/bright/Desktop/flutter_apps/rush_user_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:26: error: cannot find symbol
    flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
                                                                     ^  
  symbol:   class ImagePickerPlugin                                     
  location: package io.flutter.plugins.imagepicker                      
/Users/bright/Desktop/flutter_apps/rush_user_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:30: error: cannot find symbol
    flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
                                                                           ^
  symbol:   class SharedPreferencesPlugin                               
  location: package io.flutter.plugins.sharedpreferences                
5 errors  
Running Gradle task 'assembleDebug'... Done                       102.9s
Exception: Gradle task assembleDebug failed with exit code 1
这是我的GeneratedPluginRegistrant.java
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;

import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;

/**
 * Generated file. Do not edit.
 * This file is generated by the Flutter tool based on the
 * plugins that support the Android platform.
 */
@Keep
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
    flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin());
    flutterEngine.getPlugins().add(new io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin());
    flutterEngine.getPlugins().add(new com.baseflow.geolocator.GeolocatorPlugin());
    flutterEngine.getPlugins().add(new com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.googlemaps.GoogleMapsPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.googlesignin.GoogleSignInPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
      com.codeheadlabs.libphonenumber.LibphonenumberPlugin.registerWith(shimPluginRegistry.registrarFor("com.codeheadlabs.libphonenumber.LibphonenumberPlugin"));
    flutterEngine.getPlugins().add(new com.lyokone.location.LocationPlugin());
    flutterEngine.getPlugins().add(new com.baseflow.location_permissions.LocationPermissionsPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
    flutterEngine.getPlugins().add(new com.aboutyou.dart_packages.sign_in_with_apple.SignInWithApplePlugin());
  }
}

这是我的android文件夹结构
Android folder screen shot
我试图用谷歌搜索解决方案,但我没有找到任何与我的问题相似的建议。这是我的 flutter 医生输出
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.4 19E287 darwin-x64, locale en-KE)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
 
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.53.2)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.
这是我的依赖项
dependencies:
  flutter:
    sdk: flutter
  carousel_slider: ^2.3.1
  intl_phone_number_input: ^0.5.2+2
  pinput: ^0.2.6
  cupertino_icons: ^1.0.0
  dotted_border: ^1.0.6
  dotted_line: ^2.0.2
  date_field: ^1.0.5
  intl: ^0.16.1
  image_picker: ^0.6.7+22
  flutter_rating_bar: ^3.2.0+1
  signature: ^3.2.0
  scrollable_positioned_list: ^0.1.9
  http: ^0.12.1
  shared_preferences: ^0.5.12+4
  provider: null
  google_maps_flutter: ^1.2.0
  location: ^3.2.4
  geolocator: ^5.3.2+2
  shimmer: ^1.1.2
  flutter_google_places: ^0.2.6
  google_maps_webservice: ^0.0.19
  fluttertoast: ^7.1.6
  flutter_polyline_points: ^0.2.4
  uuid: null
  google_sign_in: ^4.5.9
  sign_in_with_apple: ^2.5.4
  firebase_messaging: ^7.0.3
我尝试迁移到一个新项目并仅传输 lib、ios 和 pubspec.yaml,但错误仍然存​​在。
请帮忙!

最佳答案

经过一番汗流浃背的斗争,我决定从我得到的无数搜索结果中尝试一个随机的解决方案,瞧

flutter pub cache repair

关于java - "error: cannot find symbol"在 flutter 中为 Android 构建时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66305553/

相关文章:

java - 我应该使用 Java 8 默认方法来手动实现 Spring Data 存储库方法吗?

java - 使用 channel 将数据传送到 cometd 服务器

java - 从服务获取 SharedPreferences

java - 从字节流创建图像的最快方法是什么?

flutter - 在flutter中构建Context和state对象

java - java 方法内多个 ArrayList 初始化可能出现的内存问题

java - 我的 java 服务器在代码中间停止

android - 在 android java 类中使用 Kotlin 扩展

flutter - 将堆叠的卡片裹起来

flutter - 如何在 Flutter 中更改主题?