We will be using Flutter device apps plugin to check the required app is already installed on Android device or not. To get this plugin follow this link Device Apps.
Step 1 : Paste this dependency “device_apps: ^1.0.9” in “pubspec.yaml” file of your project and save it.
Step 2 : Now go to the dart file in which you want enter the code to detect the required app is installed or not. Create a function as shown below as an example.
Step 3 : Here “com.example.myapp ” is package name of the app thru which the app will be search inside your device. After adding this code you will need to import device apps library in your dart file as shown below.
Step 4 : Now use the above mentioned function “Check” under any Button with “on tap” property. This function will give value “True” if it finds the mentioned app or value “False” if the app is not in your device as shown below.
Step 5 : Here we have received value as “true” in “DEBUG CONSOLE” which shows that the app is already installed in the device.
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
Run flutter pub run flutter_launcher_icons:main command from terminal
Wait for below output
Android minSdkVersion = 16
Creating default icons Android
Adding a new Android launcher icon
Overwriting default iOS launcher icon with new icon
Then reinstall the app into your handset
Hey You got the launcher icon Congrats
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
how to Prepare an android app for release in flutter?
Step 1 : First review the app manifest file
in case of flutter you will get app manifest file here at location <app dir>/android/app/src/main
step 2 : Please check your package name this will be your app unique id in playstore ( How to change package name in flutter ) step 3 : Please check permission in same file Android Manifest file
Internet permission should be there if your app need an internet access. if your app does not need internet access then remove the internet permission line
step 4 : Review the build configuration in file build.gradle at folder location <app dir>/android/app/step 5 : check the default id in build.gradle file . This should be matched with Android Manifest file package name. You can change minsdkversion and targetsdkversion here only. In case of flutter versioncode and version name will be picked from pubspec.yaml file. step 6: Add the launcher icon
add dev dependency in pubspec.yaml and place icon.png under images folder
flutter pub get
flutter pub run flutter_launcher_icons:main
Step 7: sign the app by creating keystore file
You need to sign the app digitally to upload it into playstore
Run command
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
In My Case it is " C:\Program Files (x86)\Java\jdk1.8.0_151\bin>keytool -genkey -v -keystore E:\pro jects\flutterprojects\santeyalibota/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key"
step 8. reference the keystore file from the app
create file at <app dir>/android/key.properties
and load it with your data
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, e.g. /Users/<user name>/key.jks>
Note: Keep this file private; do not check it into public source control.
step 9 : configure signing in build.gradle file
Replace:
android {
with the keystore information from your properties file:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
Replace:
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
}
}
with:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Release builds of your app will now be signed automatically.
Step 10: Enable Proguard
Create /android/app/proguard-rules.pro file and add rules listed below.
#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.** { *; }
The configuration above only protects Flutter engine libraries.
Step 11 : Enable obfuscation
Open /android/app/build.gradle file and locate buildTypes definition. Inside release configuration set minifiyEnabled and useProguard flags to true. You have to also point ProGuard to the file you have created in previous step
android { ... buildTypes { release { signingConfig signingConfigs.release minifyEnabled true useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
Note: Obfuscation and minification can extend compilation time of the Android application.
Step 12 : build the release apk
Using the command line:
cd <app dir> (replace <app dir> with your application’s directory).
Run flutter build apk (flutter build defaults to --release).
The release APK for your app is created at <app dir>/build/app/outputs/apk/release/app-release.apk.
Step 13 : install the release apk on a device
Connect your Android device to your computer with a USB cable.
cd <app dir> where <app dir> is your application directory
Run flutter install .
Step 14 : Publishing an APK to the Google Play Store
Thats it
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
Once the whole code is written, run below written commands under terminal window:
flutter packages get flutter packages pub run flutter_launcher_icons:main
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
Last Step is to change the Directory name under AndroidFolder:
Before
android\app\src\main\java\com\example\name
\com –> \your
\example –> \package
After change
android\app\src\main\java\your\package\name
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.
First, I renamed android-sdk-path\tools to android-sdk-path\tooltest.
Run sdkmanager –update in tooltest\bin.
Ignore the warning and wait until the update is done.
There will be a new folder named tools in android-sdk-path.
Copy all the files in tools folder and paste them to tooltest folder.
Overlay all the files that which has the same name in tooltest folder.
Finally,delete tools folder and rename tooltest to tools.
Is this solved?????? Oh yes its solved
* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.