Flutter Picking Wrong Keystore path and giving error key.jks not found - dart

I followed all the steps on the Flutter official site and thought I'd done everything correctly but it is failing to locate the keystore file when I build it.
This is the error message I get showing it taking wrong path instead of
D:\flutterapps\testapp\key.jks:
PS D:\flutterapps\testapp> flutter build apk
Initializing gradle... 1.3s
Resolving dependencies... 4.3s
Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks' not found for signing config 'release'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Gradle task 'assembleRelease'... Done 5.3s
Gradle task assembleRelease failed with exit code 1
PS D:\flutterapps\testapp>

On Windows you have to use 2 backslashes to indicate the path separation.
In your key.properties, you should have something like this:
storeFile=D:\\flutterapps\\testapp\\key.jks
You don't need to copy your key.jks file to your flutter project.

modified key.properties file with
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks
instead of this
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=D:\flutterapps\testapp\key.jks
and also moved key.jks to
D:\flutterapps\testapp\android\app\key.jks
as this path shown in error inside terminal
Thanks all.

it's wherever call it from in your build.gradle. insert this:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
and call this in above your android{}:
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
and that key.properties file (which should be in your root android folder) should have this:
storePassword=12345
keyPassword=12345
keyAlias=key
storeFile=/Users/me/somekey.jks

Yeah, for me... I forgot to change my signingConfig to singingConfigs.release in my build.gradle file.
buildTypes {
release {
//CHANGE THIS TO RELEASE
signingConfig signingConfigs.debug
}
}

In build.gradle
Replace
def keystorePropertiesFile = rootProject.file('key.properties')
to
def keystorePropertiesFile = rootProject.file('app/key.properties')

I was having the same issue, I ended up having quotes around my path.
In key.properties, change
storeFile="D:\\mypath\\tokeystore\\key.jks"
to
storeFile=D:\\mypath\\tokeystore\\key.jks

Related

Flutter Plugin project :sign_in_apple not found. Please update settings.gradle

Facing this issue when building the flutter project in Android 31.
ERROR:
Plugin project :sign_in_apple not found. Please update settings.gradle.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/myusername/fluttersdk/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 421
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Cannot invoke method afterEvaluate() on null object
You can just replace this code into the
android>>settings.gradle
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
Check out the steps for adding Apple SignIn to android.
https://pub.dev/packages/sign_in_with_apple
Have run into a similar issue and although the suggestion above works (manually changing the gradle rule to look for the .flutter-plugins file) this should be handled by the default android/settings.gradle file.
The root cause for me turned out to be that the plugin's pubspec.yaml didn't have a
flutter:
plugin:
platforms:
android: # <-- was missing
...
entry. This in return caused it not to show up in android plugins of the .flutter-plugins-dependencies file, which in turn made the flutter gradle rules not pick up the dependency
(The .flutter-plugins file is deprecated in favor of .flutter-plugins-dependencies).

How do I add flutter_local_notifications to my app?

I wanna add notification in my app with flutter_local_notifications but once I add the plugin to my .yaml, my app doesn't run again.
Below is the error
```D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/2.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/3.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/6.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/7.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/8.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/9.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/10.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/11.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/12.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/13.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/14.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/15.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/16.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/17.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/18.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/19.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/20.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/21.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/22.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/23.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/24.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/25.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/26.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/27.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/28.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/29.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/30.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/31.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/32.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/33.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/34.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/35.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/36.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/37.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/38.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/39.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/40.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/41.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/42.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/43.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/44.jar, /Users/macbook/AndroidStudioProjects/restaurant/build/app/intermediates/transforms/dexBuilder/debug/45.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 29s
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See ... for more information on the problem and how to fix it.
Finished with error: Gradle task assembleDebug failed with exit code 1```
Thanks.
First you need to upgrade all the packages that you have to the version where they are compatible with AndroidX. You can know that from the ChangeLog.md of each package on the dart packages page. Next you need to open the android project of your flutter in AndroidStudio, then select Refactor->Migrate to AndroidX. Wait a bit until android studio refactors your project. And the run rebuild project from android studio. It should work then!

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

Passing command Line Arguments for grails run-app through gradle task

I have a grails 3 application for which I am trying to pass command line arguments to my application when I am running it through gradle bootRun task.
I want to read the arguments in my config file for runtime operations. As per the grails documentation for yml configration here I tried to add the following to my build.gradle file
run {
systemProperties = System.properties
}
When I add that configuration and run my task I get the following error:
3:11:20 PM: Executing external task 'bootRun -Dcolor=red -Dfruit=apple'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\docs\projects\jet\build.gradle' line: 85
* What went wrong:
A problem occurred evaluating root project 'jet'.
> Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.892 secs
Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
3:11:32 PM: External task execution finished 'bootRun -Dcolor=red -Dfruit=apple'.
Please let me know if there is anything I am missing here or if there is a better way of doing this.
So I find out what the issue was.
Grails 3.0 uses bootRun as target instead of run. Changing adding the below code fixed the issue.
bootRun {
systemProperties = System.properties
}
Hope this helps everyone.

Settings Bundle in xcode for iphone

I'm trying to set my build version and build date in my app in settings bundle following this tutorial.
But I keep getting this error no matter what:
line 9: File Doesn't Exist, Will Create: /Volumes/Work Invalid
Arguments + 1: syntax error: invalid arithmetic operator (error token
is "'t Exist, Will Create: /Volumes/Work Invalid Arguments + 1")
Command /bin/sh failed with exit code 1
Could somebody please help me....
Thanks in advance.
Ok , I found the mistake : when we post, revers quotes are use to formate the message. So, please replace all  by a reverse quote `
echo "#define BUILD_DATE #\"date "+%d/%m/%Y %H:%M"\"" > build.h
build, and check your build.h
My solution is to create a build.h header with the build date (build version is related to build date), and use this from my app to display the App version + build date.
Of course, build.h need to be refresh each time you build your App.
So, here is how I do this :
Select your Targets (where you can set Bundle ID ...) / Build Phases. Go to menu Editor/Add Build Phase/Add Run Script Build Phase. Move the new created line (Run Script) up to the line "Compile sources" (use drag&drop).
open the line "Run script", and replace Type a script... with :
echo "#define BUILD_DATE #\"date "+%d/%m/%Y %H:%M"\"" > build.h
Now each time you will build, build.h will be re-create.
So, now you need to build => you will have your 1st build.h avail at root of your project.
Add it to your project.
Now, import build.h in the VC where you need the information.
Here is how I use it (I have a iboultet to a label)
- (void)viewDidLoad
{
[super viewDidLoad];
//cf http://stackoverflow.com/questions/3015796/how-to-programmatically-display-version-of-target-in-iphone-app-xcode
NSString * appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"];
self.version.text = [NSString stringWithFormat:#"v %# %#", appVersionString,BUILD_DATE];
}

Resources