1

I have created an app in flutter using Android studio which I want to deploy.

Flutter version is 2.10.

Dart version is 2.16.0.

When I run or debug main.dart from Android studio everything works as expected. I have signed the application following the instructions from here:

https://docs.flutter.dev/deployment/android

I have created the keystore using the following command:

"C:\Program Files\Android\Android Studio\jre\bin\keytool" -genkey -v -keystore c:\upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

Created key.properties file with the following content

storePassword=password from previous step
keyPassword=password from previous step
keyAlias=key
storeFile=location of the key store file, such as /Users/<user name>/upload-keystore.jks

in [project]/android/app/build.gradle added the keystore information before the Android block as follow

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

and replaced

   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 keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

And after changing the gradle file I ran flutter clean. After the specified steps the application can still the debugged and can be ran as expected. I am building a bundle with the following command

flutter build appbundle

The build is successful and I get the output file in

build\app\outputs\bundle\release\app-release.aab

Using bundletool I convert the .aab file to apks and install it on my phone with the following commands:

java -jar "PATH/bundletool-all-1.8.2.jar" build-apks --bundle=PATH/app-release.aab --ks="PATH/upload-keystore.jks" --ks-key-alias=key --output=PATH/app-release.apks
java -jar "PATH/bundletool-all-1.8.2.jar" install-apks --apks=PATH/app-release.apks

where PATH is the path to the directory of the file. After the app is being installed and launched I get the attached window

enter image description here

which is completely different than the app I wrote.

Can someone please tell me what am I doing wrong?

Best regards, Stanko

2
  • I see no reason why app from APK should be different than made by flutter. Are you sure you are in right folder? Have you tried launch it by flutter run command? Commented Feb 24, 2022 at 15:02
  • You're right Tomas, flutter run is indeed running the program from the screenshot. But when I run the programing using ALT+SHIFT+F9 (Debug) or ALT+SHIFT+F10 (Release) in Android Studio a different app is starting. Is there a way to check the run path or specify another build path ? Thank you for your time! Stanko Commented Feb 24, 2022 at 17:11

1 Answer 1

1

Thanks to Tomas's comment I have found the solution. Running the following command

flutter run

a different project has been started, so I had to use this instead

flutter run PATH/lib/src/main.dart

which started the correct project, similarly for the app bundle I had to run

flutter build appbundle PATH/lib/src/main.dart

Thank you for your help!

Best wishes, Stanko

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.