升级颤动打破了依赖关系

时间:2019-05-09 18:37:15

标签: android gradle flutter firebase-authentication

我刚刚将Flutter升级到1.5,将Android Studio升级到3.4,并且我的依赖项(可提及的Firebase)和我的应用程序不再在设备上运行。它正在安装中,直接崩溃并显示以下错误:

  

java.lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / firebase / auth / FirebaseAuth;

将flutter降级到较旧的版本并降级Android Studio均无效。我个人的假设是,这与从ProGuard到R8的更改有关。

这是我当前的 proguard-rules.pro 文件的外观:

 #Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-keep class com.google.firebase.** { *; }

我的依赖项:

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.2.0'
}

app / build.gradle:

minSdkVersion 21
targetSdkVersion 28
...    
minifyEnabled true
useProguard true

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

颤抖的医生:

[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17763.475], locale de-AT)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] IntelliJ IDEA Ultimate Edition (version 2018.3)
[!] VS Code, 64-bit edition (version 1.33.1)
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)

pubspec.yaml

version: 1.0.0+1
environment:
  sdk: ">=2.1.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  image_picker:
  path_provider:
  google_maps_flutter:
  firebase_core:
  firebase_auth:
  cloud_firestore:
  image_cropper:
  firebase_storage:
  font_awesome_flutter:
  google_sign_in:
  flutter_facebook_login:
  http:
  location:
  geoflutterfire:
  firebase_messaging:
  cached_network_image:
  share:
  camera:
  flutter_staggered_grid_view:

3 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,因为我的问题是由于尺寸缩小, 尝试设置

minifyEnabled false

拍打干净 然后构建您的项目

答案 1 :(得分:0)

将您的依赖项更改为此

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.2.0'
        implementation 'com.google.firebase:firebase-auth:17.0.0'
}

还要注意这一点,如果您使用的是Firebase消息传递等其他插件,则还需要添加它。

此处列出了新版本

https://developers.google.com/android/guides/releases

有关此更改的另一件事,您需要将Flutter Firebase插件更新到最新版本,否则将遇到稳定性问题和意外崩溃。

答案 2 :(得分:0)

更改了最新的Firebase消息传递的Google依赖项,并在应用gradle文件的同一版本中修改了其他依赖项。现在工作正常

dependencies version detail you can refer here

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
}