Posts

Showing posts from May, 2020

Flutter app crashing without any logs when building in debug mode.

Here are the several problems of the crashing flutter app when making a debug build. First of all, it's always right to see the debugging messages. But what if the messages are not shown in default IDE? Capturing debug log in Visual Studio Code Press Ctrl + Shift + P and type Dart:Capture Logs and click OK Now start debugging your code. Run > Start Debugging You will see debug log messages which is useful to find out what went wrong! Some possible cause of app crashings Did you install new plugin and missing it's meta information in androidmanifest.xml? For example, if you're using admob plugin, you need to declare AdmobAppID in manifest file and if you didn't your app may crassh. <meta-data android :name ="com.google.android.gms.ads.APPLICATION_ID" android :value ="@string/admob_app_id" />

Publishing Flutter app

Reference https://flutter.dev/docs/deployment/android Making release build to the device flutter run --release -d <YourDeviceID from adb devices> Building app bundles with code obfuscations flutter build appbundle --obfuscate --split-debug-info=/debug_info Building universal apk flutter build apk --obfuscate --split-debug-info=/debug_info Building apk for 32bit flutter build apk --target-platform=android-arm --obfuscate --split-debug-info=/debug_info Building apk for 64bit flutter build apk --target-platform=android-arm64 --obfuscate --split-debug-info=/debug_info Spliting apk flutter build apk --split-per-abi --obfuscate --split-debug-info=/debug_info Building for web Switch to beta channel flutter channel beta Note : If the blank screen error occur, go to dev channel flutter channel dev Upgrade to get the latest build flutter upgrade Enable web support flutter config --enable-web Check whether the required chrome debugger is instal...

Increasing the character length before auto reformat dart code while saving in VSCode

When Visual studio automatically wrap code when you pressed Ctrl + S and you feel that it wrap codes in too many lines because the default characters limit is too low for your monitor. How to fix? File > Preferences > Settings Search for Dart : Line length and change from 80 to 160 Search for ruler and click Edit in settings.json and change from 80 to 160 and press Ctrl + S to save.. Done! For Webstorm, Preferences > Editor > CodeStyle >Dart > Change character length

Creating a new visual studio code extension

Project start Install yo npm package npm i -g yo Now go to your project folder and genearte template using yo Open command prompt yo code Building the extension Make sure that you have publisher names and other requirement information in the package.json file Make sure that you edit Readme.md file "categories": [         "Other",         "Snippets"     ],     "keywords": [         "flutter",         "keywords01",         "keywords02"       ],     "publisher": "yourname",     "icon": "local/path/to/icon",     "author": {         "email": "youremail@gmail.com",         "name": "Your name",         "url": "Your github page"     },     "license": "MIT",     "contributors": [         { ...

Common Errors

adb: failed to install E:\FlutterProjects\learn_english\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE] To solve this issue, close the currently opened emulator. Go to AVD manager from Android Studio > Tools Selection More icon in the action tab of your virtual device and choose Wipe data Weird guawa conflict error when building with firebase services  Add the following line in the build.gradle file dependencies implementation 'com.google.guava:guava:27.0.1-android'

Integrating Admob

Create a new admob app from the following link https://apps.admob.com/v2/apps In flutter add the following lines in the strings. <string name="admob_app_id">YOUR_ADMOB_APP_ID</string> In the AndroidManifest.xml file add the following lines <meta-data                 android:name="com.google.android.gms.ads.APPLICATION_ID"                 android:value="@string/admob_app_id"/> And follow the sample codes below to start showing your ads in the application. Banner and interstitial ads can be configured with target information. And in the example below, the ads are given test ad unit IDs for a quick start. MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( keywords: < String >[ 'flutterio' , 'beautiful apps' ], contentUrl: 'https://flutter.io' , birthday: DateTime .now(), childDirected: false , designedForFamilies: false , gender: MobileAdGender.male...

Integrating firebase services

Create a new firebase project In the project settings > General > Add App, register a new platform (android) Download google-services.json file and put it under android->app in the Flutter project //Add the following lines in the project level build.gradle (android > build.gradle) buildscript {   repositories {     // Check that you have the following line (if not, add it):     google ()   // Google's Maven repository   }   dependencies {     ...     // Add this line     classpath 'com.google.gms:google-services:4.3.3'   } } allprojects {   ...   repositories {     // Check that you have the following line (if not, add it):     google ()   // Google's Maven repository     ...   } } //Add the following lines in the app level build.gradle (android > app > build.gradle) apply plugin: 'com.android.application' // Add this line apply ...

Changing Package/Version name in Flutter

Image
Start from Dec 2019, for  package name  just change in build  build.gradle  only defaultConfig { applicationId "your.package.name" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } If you need to change your version name and code, you need to specify in pubspec.yaml change the version to whatever version you want + (plus sign) is for versionCode For iOS Change the bundle identifier from your  Info.plist  file inside your  ios/Runner  directory. < key > CFBundleIdentifier </ key > < string > com . your . packagename </ string >