Проблемы с созданием Flutter APK на Android после установки FirebaseAndroid

Форум для тех, кто программирует под Android
Ответить
Гость
 Проблемы с созданием Flutter APK на Android после установки Firebase

Сообщение Гость »

Я пишу приложение для Android на Flutter. Изначально, когда я создал APK, он корректно работал на устройстве. Однако после настройки приложения для использования облачного сообщения Firebase (в основном в pubspec.yaml и различных исходных файлах .dart) оно создает APK, который не работает.
пытался очистить /восстановить кэш дротика --> ничего
пробовал flutter pub get/upgrade/outdated --> ничего
это файлы в моем проекте:
  • android\app\src\main\AndroidManifest.xml:
  • это «GeneratedPluginRegistrant.java»:

Код: Выделить всё

package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
* 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 {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin firebase_core, io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin firebase_messaging, io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin", e);
}
}
}

[*]это «app/build.gradle»:

Код: Выделить всё

plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

android {
namespace "com.example.studioc5"
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.studioc5"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {}

  • это зависимости в pubspec.yaml:

Код: Выделить всё

  cupertino_icons: 1.0.6
firebase_messaging: 14.7.4
firebase_core: 2.27.0
http: 1.2.0
rounded_expansion_tile: 0.0.13

  • это main.dart (*** заменяет реальные данные):

Код: Выделить всё

void main() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

runApp(const MyHomePage());
}
как я уже сказал, пытался восстановить/сбросить кеш, переустановил студию Android, создал новый проект флаттера, попытался вручную изменить зависимости pubspec.yaml, переустановить SDK флаттера... ничего работает.

Источник: https://stackoverflow.com/questions/781 ... base-setup
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»