В выпуске apk виден только серый экран Flutter
Я хотел создать релизный apk для своего приложения и попытался запустить эту команду
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Затем я запустил apk app-armeabi-v7a-release, это был только серый экран.
Я также включил все разрешения в манифесте
<uses-permission android:name="android.permission.INTERNET"/>
Бревно
WARNING: [Processor] Library 'C:\Users\sanje\.gradle\caches\modules-2\files-2.1\org.robolectric\shadows-framework\4.3\150103d5732c432906f6130b734e7452855dd67b\shadows-framework-4.3.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/test/runner/lifecycle/Stage'
Example of support library reference: 'android/support/annotation/NonNull'
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 107.2s
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (15.8MB).
Android / приложение / build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.maslow.learnwithyoutube_flutterapp"
minSdkVersion 21
targetSdkVersion 30
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 {
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
local.properties
sdk.dir=C:\\Users\\sanje\\AppData\\Local\\Android\\Sdk
flutter.sdk=C:\\flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1
ИГНОРИРУЙТЕ ЭТО: Lorem ipsum dolor sit amet, conctetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud упражнение ullamco labouris nisi ut aliquip ex eamodo consquat. Duis aute irure dolor в репрехендерит в сладострастном velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, загорелся in culpa qui officia deserunt mollit anim id est Laborum.
Версия Flutter
Flutter 1.22.6
Заранее спасибо!
1 ответ
После 2 часов поисков я нашел решение.
В моем случае это из-за пакета flutter_downloader.
добавить блок try catch в main следующим образом:
void main() async {
try {
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize(
debug: true // optional: set false to disable printing logs to console
);
await Firebase.initializeApp();
final Directory directory =
await path_provider.getApplicationDocumentsDirectory();
Hive.init(directory.path);
Hive.registerAdapter(ResponseTokenModelAdapter());
await Hive.openBox<ResponseTokenModel>(HiveBoxNames.token);
configureInjection(Environment.prod);
runApp(AppWidget());
} catch (e) {
runApp(MaterialApp(
home: Center(
child: Text(e.toString()),
),
));
}
}
Теперь мне просто нужно добавить встроенную интеграцию.