Hey guys, my debug apk seems to be working fine, but the release apk I generate is crashing .... What could have gone wrong?

292 views
Skip to first unread message

srinidhi prasad

unread,
Feb 12, 2022, 5:44:56 AM2/12/22
to Flutter Development (flutter-dev)
Here's my app\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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
lintOptions {
abortOnError false
}
flavorDimensions "Doctor-type"

productFlavors {
doctor_dev {
dimension "Doctor-type"
applicationId "com.medicall.doctor"
resValue "string", "app_name", "Doctor_Dev"
}
doctor_prod {
dimension "Doctor-type"
applicationId "com.medicall.doctor"
resValue "string", "app_name", "Doctor_Prod"
}
patient_dev {
dimension "Doctor-type"
applicationId "com.medicall.patient"
resValue "string", "app_name", "Patient_Dev"
}
patient_prod {
dimension "Doctor-type"
applicationId "com.medicall.patient"
resValue "string", "app_name", "Patient_Prod"
}
}

compileSdkVersion 30
buildToolsVersion '29.0.0'
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
// disable 'InvalidPackage'
// abortOnError false
// checkReleaseBuilds false
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.medicall.app"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.android.support:multidex:1.0.3'
}

apply plugin: 'com.google.gms.google-services'


And here's my android build gradle 

buildscript {
ext.kotlin_version = '1.4.32'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}

}

allprojects {
repositories {
google()
jcenter()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}

And here's my main dart file


import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:quickblox_sdk/chat/constants.dart';
import 'package:quickblox_sdk/quickblox_sdk.dart';
import 'package:rxdart/rxdart.dart';

import 'AppController/App.dart';
import 'AppController/flavors.dart';
import 'Repos/SharedPrefRepo.dart';
import 'Services/NotificationService.dart';
import 'SharedPrefRepoImpl.dart';
import 'Utils/Constants.dart';
import 'Utils/VideoCallHelper.dart';

final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();

/// Streams are created so that app can respond to notification-related events
/// since the plugin is initialised in the `main` function
final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject = BehaviorSubject<ReceivedNotification>();

final BehaviorSubject<String> selectNotificationSubject = BehaviorSubject<String>();

final BehaviorSubject<String> chatConnectionListener = BehaviorSubject<String>();

dynamic fcmMessage;
bool appLaunchedFromNotification = false;
bool callScreenOn =false;

const MethodChannel platform = MethodChannel('dexterx.dev/flutter_local_notifications');

Future<void> _messageHandler(RemoteMessage message) async {
print('background message ${message.notification.body}');
}

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {

print('Message from fcm : $message');
dynamic data,notification;
if (message.containsKey('data')) {
// Handle data message
print('fcm >>>>> message:'+message.toString());
data = message['data'];
print('fcm >>>>> data:'+data.toString());

if(data.containsKey('sessionId')) {
String sessionId = data['sessionId'];
print('fcm >>>>> sessionId:' + sessionId);
String name = data['name'];
print('fcm >>>>> name:' +name);
String userId = data['userId'];
print('fcm >>>>> userId:' +userId);
String clId = data['clId'];
print('fcm >>>>> clid:' +clId);
int callTime = int.tryParse(data['time']);
print('call time: $callTime');
int currTime = DateTime.now().millisecondsSinceEpoch;
int diff = currTime - callTime;
print('call time diff'+diff.toString());
if(currTime-callTime<=45000) {
appLaunchedFromNotification = true;
NotificationService().showCallNotification(data, name);
}else{
String title = 'Missed call from $name';
if(title!=null) {
NotificationService().showNotification(title, '');
}
}
}
}

if (message.containsKey('notification')) {
// Handle notification message
print('fcm >>>>> message:'+message.toString());
notification = message['notification'];
print('fcm >>>>> notif:'+notification.toString());
}
}

_listenForChatConnections() async{
try {
var _connectedSubscription = await QB.chat.subscribeChatEvent(QBChatEvents.CONNECTED,(data) {
print('chat CONNECTED status: $data');
//QB.webrtc.init();
});

await QB.chat.subscribeChatEvent(QBChatEvents.CONNECTION_CLOSED,(data) {
print('chat CONNECTION_CLOSED status: $data');
});

await QB.chat.subscribeChatEvent(QBChatEvents.RECONNECTION_SUCCESSFUL,(data) {
print('chat RECONNECTION_SUCCESSFUL status: $data');
//QB.webrtc.init();
});

} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
}
}
void main() async{
F.appFlavor = Flavor.DOCTOR_DEV;
WidgetsFlutterBinding.ensureInitialized();

WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_messageHandler);

_initFCM();
_initNotifications();
_initQuickblox();
_listenForChatConnections();

SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]).then((value) => runApp(App()));
}

_initQuickblox() async {
try {

SharedPrefRepo sharedPrefRepo = SharedPrefRepoImpl();
await QB.settings.init(
Constants.APP_ID,
Constants.AUTH_KEY,
Constants.AUTH_SECRET,
Constants.ACCOUNT_KEY,
apiEndpoint: Constants.API_ENDPOINT,
chatEndpoint: Constants.CHAT_ENDPOINT);

print('sdk initialized,will login to QB');
String _username = await sharedPrefRepo.getString(Constants.PHONE_NUMBER);
if(_username!=null) {
print('logging in to QB with $_username');
await VideoCallHelper.loginToQuickblox(_username);
}else{
print('username is null');
return -1;
}

} on PlatformException catch (e) {
// Some error occured, look at the exception message for more details
print('error while initializing quickblox sdk'+e.toString());
}
}
_initFCM() async{
await Firebase.initializeApp();
}

_initNotifications() async{

const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('ic_launcher');

/// Note: permissions aren't requested here just to demonstrate that can be
/// done later
final IOSInitializationSettings initializationSettingsIOS =
IOSInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
onDidReceiveLocalNotification:
(int id, String title, String body, String payload) async {
didReceiveLocalNotificationSubject.add(ReceivedNotification(
id: id, title: title, body: body, payload: payload));
});

final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: (String payload) async {
if (payload != null) {
debugPrint('notification payload: $payload');
}
final NotificationAppLaunchDetails details =
await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails();

print("test me !-> ${details.payload}");
selectNotificationSubject.add(details.payload);
});
}


Please help me through this process

Manish sharma

unread,
Feb 12, 2022, 5:55:41 AM2/12/22
to srinidhi prasad, Flutter Development (flutter-dev)
after the app development, this article will help you 

How to Promote Mobile Game App?


--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/8293a614-4c68-4e53-b2f6-659d591ba89an%40googlegroups.com.

Boluwatife Atanda

unread,
Feb 15, 2022, 12:35:13 AM2/15/22
to Flutter Development (flutter-dev)
Hey, follow the instructions on this link: https://docs.flutter.dev/deployment/android 
Reply all
Reply to author
Forward
0 new messages