Appcenter: Flutter Support

Created on 14 Feb 2019  ·  82Comments  ·  Source: microsoft/appcenter

Describe the solution you'd like
Adding a support for Flutter projects would be awesome, (importing, building, etc)

Describe alternatives you've considered
None.

feature request platform

Most helpful comment

This is one the team is definitely keeping an eye on to track the interest.

All 82 comments

This is one the team is definitely keeping an eye on to track the interest.

Looking forward to this.

It seems an iOS Flutter app can get built via appcenter. For android, it fails to find the necessary android files with the same project.
Figured out this issue ^^

Turns out you can build a flutter app but its not plug and play.

@nate-eisner care to share your solution? - I have the same issue even after using the build scripts found here: https://github.com/Microsoft/appcenter-build-scripts-examples/tree/master/flutter

App center finds our iOS project, but with android it fails to identify the project in the Repo.

@nate-eisner care to share your solution? - I have the same issue even after using the build scripts found here: https://github.com/Microsoft/appcenter-build-scripts-examples/tree/master/flutter

App center finds our iOS project, but with android it fails to identify the project in the Repo.

@darrencrossley
What was missing for me was the gradle wrapper files. They use those to detect that this is an android project.

Make sure you commit android/gradle/wrapper/gradle-wrapper.jar , android/gradlew, and android/gradlew.bat

@darrencrossley and @nate-eisner , Check this issue - https://github.com/flutter/flutter/issues/30858

Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me.

Any update?

@RenanDelfanti not yet. Still something we're looking at, talking with customers, etc. Do you have to chat with us about the apps you're building using Flutter?

@jwargo Thanks for the answer! I tried to build my app with the post script and everything worked great!

Happy to see so many builds working with the addition of the build scripts. We're very curious to hear what services matter to those of you working on Flutter. Where else in App Center would you be looking for Flutter support?

Happy to see so many builds working with the addition of the build scripts. We're very curious to hear what services matter to those of you working on Flutter. Where else in App Center would you be looking for Flutter support?

@nrajpurkar In my current project, I would like to unify my builds and analysis in appcenter.
I suggest a dart package to support Analytics of appcenter.

Happy to see so many builds working with the addition of the build scripts. We're very curious to hear what services matter to those of you working on Flutter. Where else in App Center would you be looking for Flutter support?

@nrajpurkar Full Flutter support and be able to possibly run Flutter tests as well, that way AppCenter can compete w/ codemagic.io

I've actually moved to codemagic because appcenter doesn't support this. I actually find it a lot easier to use.... But VSAC can win me back if they add Flutter support :)

@lewcianci thanks, we'll keep pushing for it.

I want to share my experience, to hopefully help save others some time when going down this path.

It did not seem clear or up-front that _App Center does not support Flutter_.

After few searches online, you will find several build scripts and Medium/other articles walking through how to setup Flutter CI with App Center. Microsoft(App Center) hosts post-clone build scripts for this exact purpose as others have pointed out, here: https://github.com/microsoft/appcenter/tree/master/sample-build-scripts/flutter.

None of this worked for me.

After talking with App Center support for a week or so I got the following response:

Currently Flutter build is not supported and I have already tagged this as a feature request +1 for our production team to review.
Do you mind making your feature request on our Github repo: https://github.com/Microsoft/appcenter/issues
You may also search there to see if it has already been submitted. In that case, please 👍 the issue to show your interest. You can also check to see if it is in our upcoming iteration plan: https://github.com/Microsoft/appcenter/wiki/Iteration-Plans

This response contradicts some of the replies on this issue. Users indicate that they were able to get Flutter CI working in App Center, perhaps without 'full' support. ¯_(ツ)_/¯

That said, App Center is an amazing tool. Our team has been using it for our React Native project for a few years with no issues, and we hope to be able to do so in the future as we explore other mobile frameworks.

@c3bryant I apologize for the issues you faced. Flutter is not a supported platform on App Center although it is something we're considering (and I personally want to see happen). It shouldn't be listed anywhere as a supported platform as we don't usually list what platforms we don't support :-)

We do have customers that have gotten it to work for one or more services and we published those build scripts to help customers who want to hack away at it with them until we add formal support. There are even developers who've built Flutter wrappers around our SDK and use them in production apps without issue. That's all we have to offer until we add formal support for the platform/framework.

We were building flutter apps for iOS with no problem but it stopped working. Now it says "CocoaPods installed but not initialized. Skipping pod install." and "To initialize CocoaPods, run:
pod setup". I added pod setup as requested on the post build script but it also didn't work. Anyone else with this issue?

Having the same issue for a few days now

@jeffaknine my colleague just found a way to resolve this. Force the installation of Cocoapods:

#!/usr/bin/env bash
#Place this script in project/ios/

# fail if any command fails
set -e
# debug log
set -x

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel stable
flutter doctor
flutter pub get

echo "Installed flutter to `pwd`/flutter"

flutter build ios --release --no-codesign

@luismarquesfreire I already have the "uninstall" and "install" and I have the following problem : "The Podfile does not contain any dependencies"
"CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target Runner to Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig or include the Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig in your build configuration (Flutter/Release.xcconfig)."
Any ideas ?

@jeffaknine are you using the script exactly as I provided? It seems that you're running pod install but you can't. Flutter build will do it for you. Remove pod install from your script. You can actually see Podfile file and see that there are no dependencies there, that's because flutter handles it for you with the dependencies stated at pubspec.

@jeffaknine my colleague just found a way to resolve this. Force the installation of Cocoapods:

#!/usr/bin/env bash
#Place this script in project/ios/

# fail if any command fails
set -e
# debug log
set -x

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel stable
flutter doctor
flutter pub get

echo "Installed flutter to `pwd`/flutter"

flutter build ios --release --no-codesign

Thanks @luismarquesfreire,
Our iOS builds are now working again :) ...
We were using the same method to fix this as well but had the uninstall/install cocoapods after "clone flutter" and it wasn't working.

it works also for me (in the appcenter-post-clone.sh script).
Thank you

is this going anywhere?

Building the app through App Center pipeline is one thing but having the SDK for crashes, analytics, push notifications etc. is another. It would be great if App Center could support Flutter - we use App Center with all our React Native apps but we are seriously considering developing our upcoming projects with Flutter.

@filiphosko how many apps? How many users are we talking here? Feel free to email me (email address is in my GitHub profile).

It would be nice to have flutter support in Appcenter. My company has MS business solutions and we add apps in appcenter for internal purpose. Now we think to use flutter for our app development, and there for we need that Appcenter support flutter.

@webskydavid how many apps? How many users are we talking here? Feel free to email me (email address is in my GitHub profile).

I'm trying to build my flutter app using the above workaround however I'm getting a generic gradle error.

Can someone help?

Installed flutter to /Users/runner/runners/2.160.1/work/1/s/flutter
Running "flutter pub get" in s...                                   9.1s
Initializing gradle...                                             10.5s
Resolving dependencies...                                       
* Error running Gradle:
ProcessException: Process "/Users/runner/runners/2.160.1/work/1/s/android/gradlew" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
Gradle 5.6.2

Please review your Gradle project setup in the android/ folder.
##[error]/bin/bash failed with return code: 1
##[error]Bash failed with error: /bin/bash failed with return code: 1

We are looking forward for this feature.

Using Codemagic (really good tool) but it lacks integration with custom SSO, and our policies require that to be available.

Could not find official SDK for flutter, end up building one that wraps up android / ios SDK . https://pub.dev/packages/flutter_appcenter_bundle

Any news about Official SDK and Flutter support ?

I'm getting the below error when running Flutter project in Appcenter.

> Configure project :
Resolved com.android.tools.build:gradle:3.5.0 in :classpath 
Resolved org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50 in :classpath 

> Configure project :app
Project app at :app is either no Android app project or build version has not been set to override. Skipping...

> Configure project :
Project android at : is either no Android app project or build version has not been set to override. Skipping...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/runners/2.165.0/work/1/s/android/app/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating project ':app'.
> Flutter SDK not found. Define location with flutter.sdk in the local.properties file.

Here's my local.properties :

sdk.dir=D:\\Applns\\Sdk\\Sdk
flutter.sdk=D:\\flutter\\flutter_windows_v1.12.13+hotfix.5-stable\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

Came across this in my research.
@jwargo you noted:

It shouldn't be listed anywhere as a supported platform as we don't usually list what platforms we don't support :-)

I've whipped up a quick readme to state that and point to this feature request, because I think it's reasonable to have that clarification while providing the build scripts: https://github.com/microsoft/appcenter/blob/master/sample-build-scripts/flutter/readme.md

@jeffaknine my colleague just found a way to resolve this. Force the installation of Cocoapods:

#!/usr/bin/env bash
#Place this script in project/ios/

# fail if any command fails
set -e
# debug log
set -x

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel stable
flutter doctor
flutter pub get

echo "Installed flutter to `pwd`/flutter"

flutter build ios --release --no-codesign

The error I've been getting is:

Invalid Podfile file: Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first.

I was hoping your fix for your issue would work for me too, but I still get this error, no matter what I change. No idea why it works for others and not me...

My build script:

set -e
set -x

# Install the same version as the one on my machine to see if it helps!
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.1 
pod setup

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel beta
flutter doctor
flutter pub get

echo "Installed flutter to \`pwd\`/flutter"

flutter build ios --release --no-codesign

If anyone has any clues as to why this error keeps cropping up, I'd appreciate the help!

As a side note, I have sent a request to the App Center support in the chat window, and posted a question on Stack Overflow.

@rakeshh025 try updating compileSdkVersionand targetSdkVersionin build.gradle to 29.

It would really speed up the build if there were prebuilt images for each of the different channels (stable, beta, dev, etc).

I'm getting the below error when running Flutter project in Appcenter.

> Configure project :
Resolved com.android.tools.build:gradle:3.5.0 in :classpath 
Resolved org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50 in :classpath 

> Configure project :app
Project app at :app is either no Android app project or build version has not been set to override. Skipping...

> Configure project :
Project android at : is either no Android app project or build version has not been set to override. Skipping...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/runners/2.165.0/work/1/s/android/app/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating project ':app'.
> Flutter SDK not found. Define location with flutter.sdk in the local.properties file.

Here's my local.properties :

sdk.dir=D:\\Applns\\Sdk\\Sdk
flutter.sdk=D:\\flutter\\flutter_windows_v1.12.13+hotfix.5-stable\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

I'm facing same issue. Did you found any solution yet?

Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me.

How to force add these files?

Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me.

How to force add these files?

Remove them from the .gitignore file(s).

Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me.

How to force add these files?

Remove them from the .gitignore file(s).

Thanks for reply. I already remove it but getting this error

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating project ':app'.
> java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\flutter/packages/flutter_tools/gradle/flutter.gradle

* 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 13s
Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1
    at ChildProcess.<anonymous> (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:920:16)
    at Socket.<anonymous> (internal/child_process.js:351:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:509:12)
##[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1

I think issue is with this line: C:\flutter/packages/flutter_tools/gradle/flutter.gradle. Can you help?

@abdullah432
It's probably the backslash in the path, try adding a second backslash or
change it to a forward slash.

On Sun, Apr 12, 2020, 15:26 Abdullah khan notifications@github.com wrote:

Forcibly adding android/gradle/wrapper/gradle-wrapper.jar ,
android/gradlew and android/gradlew.bat did the job for me.

How to force add these files?

Remove them from the .gitignore file(s).

Thanks for reply. I already remove it but getting this error

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 26

  • What went wrong:
    A problem occurred evaluating project ':app'.

    java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\flutter/packages/flutter_tools/gradle/flutter.gradle

  • 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 13s
Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1
at ChildProcess. (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:920:16)
at Socket. (internal/child_process.js:351:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:509:12)

[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1

I think issue is with this line:
C:\flutter/packages/flutter_tools/gradle/flutter.gradle. Can you help?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/appcenter/issues/67#issuecomment-612614165,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAKNAPOSSBEEKBSNGZYD2WLRMG6PFANCNFSM4GXM64NQ
.

It's probably the backslash in the path, try adding a second backslash or change it to a forward slash.

On Sun, Apr 12, 2020, 15:26 Abdullah khan @.*> wrote: Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me. How to force add these files? Remove them from the .gitignore file(s). Thanks for reply. I already remove it but getting this error FAILURE: Build failed with an exception. * Where: Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 26 * What went wrong: A problem occurred evaluating project ':app'. > java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\flutter/packages/flutter_tools/gradle/flutter.gradle * 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 13s Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 at ChildProcess. (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:920:16) at Socket. (internal/child_process.js:351:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:509:12) ##[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 I think issue is with this line: C:\flutter/packages/flutter_tools/gradle/flutter.gradle. Can you help? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKNAPOSSBEEKBSNGZYD2WLRMG6PFANCNFSM4GXM64NQ .

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
This is actual line in my build.gradle.
When i try to build from appcenter. Above error return. I follow this link and search a lot but nothing work. Can you guess from above error. What's really the problem is?

It's probably the backslash in the path, try adding a second backslash or change it to a forward slash.

On Sun, Apr 12, 2020, 15:26 Abdullah khan _@_.*> wrote: Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me. How to force add these files? Remove them from the .gitignore file(s). Thanks for reply. I already remove it but getting this error FAILURE: Build failed with an exception. * Where: Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 26 * What went wrong: A problem occurred evaluating project ':app'. > java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\flutter/packages/flutter_tools/gradle/flutter.gradle * 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 13s Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 at ChildProcess. (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:920:16) at Socket. (internal/child_process.js:351:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:509:12) ##[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 I think issue is with this line: C:\flutter/packages/flutter_tools/gradle/flutter.gradle. Can you help? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKNAPOSSBEEKBSNGZYD2WLRMG6PFANCNFSM4GXM64NQ .

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
This is actual line in my build.gradle.
When i try to build from appcenter. Above error return. I follow this link and search a lot but nothing work. Can you guess from above error. What's really the problem is?

I see, quick fix would be to just do .replace("\", "/")

@abdullah432
But the real fix would be to really understand that this is just basic Java/Groovy and fix it correctly when defining the $flutterRoot variable.

It's probably the backslash in the path, try adding a second backslash or change it to a forward slash.

On Sun, Apr 12, 2020, 15:26 Abdullah khan _@_.*> wrote: Forcibly adding android/gradle/wrapper/gradle-wrapper.jar , android/gradlew and android/gradlew.bat did the job for me. How to force add these files? Remove them from the .gitignore file(s). Thanks for reply. I already remove it but getting this error FAILURE: Build failed with an exception. * Where: Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 26 * What went wrong: A problem occurred evaluating project ':app'. > java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\flutter/packages/flutter_tools/gradle/flutter.gradle * 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 13s Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 at ChildProcess. (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:920:16) at Socket. (internal/child_process.js:351:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:509:12) ##[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1 I think issue is with this line: C:\flutter/packages/flutter_tools/gradle/flutter.gradle. Can you help? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKNAPOSSBEEKBSNGZYD2WLRMG6PFANCNFSM4GXM64NQ .

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
This is actual line in my build.gradle.
When i try to build from appcenter. Above error return. I follow this link and search a lot but nothing work. Can you guess from above error. What's really the problem is?

I see, quick fix would be to just do .replace("\", "/")

After replacing apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" with apply from: "$flutterRoot\packages\flutter_tools\gradle\flutter.gradle"
Following error occur.

* What went wrong:
Could not compile build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle'.
> startup failed:
  build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle': 26: unexpected char: '\' @ line 26, column 26.
     apply from: "$flutterRoot\packages\flutter_tools\gradle\flutter.gradle"
                              ^

  1 error

My repository link: https://github.com/abdullah432/ruminate.git

@abdullah432
But the real fix would be to really understand that this is just basic Java/Groovy and fix it correctly when defining the $flutterRoot variable.

How i can fix this. Local build working fine. Problem occur only when building apk with appcenter?

@abdullah432
But the real fix would be to really understand that this is just basic Java/Groovy and fix it correctly when defining the $flutterRoot variable.

How i can fix this. Local build working fine. Problem occur only when building apk with appcenter?

I really meant to replace it so that you dont have \, but only /, by using a Java method.

Could you post your file on pastebin or something?

@abdullah432
But the real fix would be to really understand that this is just basic Java/Groovy and fix it correctly when defining the $flutterRoot variable.

How i can fix this. Local build working fine. Problem occur only when building apk with appcenter?

I really meant to replace it so that you dont have \, but only /, by using a Java method.

Could you post your file on pastebin or something?

Only build.gradle file?

@abdullah432
But the real fix would be to really understand that this is just basic Java/Groovy and fix it correctly when defining the $flutterRoot variable.

How i can fix this. Local build working fine. Problem occur only when building apk with appcenter?

I really meant to replace it so that you dont have , but only /, by using a Java method.
Could you post your file on pastebin or something?

Only build.gradle file?

Yes

@graknol

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: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "Application ID"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            storeFile rootProject.file("app/android.keystore")
            storePassword System.getenv("APPCENTER_KEYSTORE_PASSWORD")
            keyAlias System.getenv("APPCENTER_KEY_ALIAS")
            keyPassword System.getenv("APPCENTER_KEY_PASSWORD")
        }
    }

    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.release

            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    //facebook login
    implementation 'com.facebook.android:facebook-login:[5,6)'
}

@abdullah432
Remove flutter.sdk from the local.properties file.

@abdullah432
Also try replacing this:

def flutterRoot = localProperties.getProperty('flutter.sdk')

with this
```groovy
def flutterRoot = localProperties.getProperty('flutter.sdk').replaceAll("\", "/")

@abdullah432
Remove flutter.sdk from the local.properties file.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating project ':app'.
> Flutter SDK not found. Define location with flutter.sdk in the local.properties file.

@abdullah432
Also try replacing this:

def flutterRoot = localProperties.getProperty('flutter.sdk')

with this

def flutterRoot = localProperties.getProperty('flutter.sdk').replaceAll("\\", "/")
> Configure project :
Project android at : is either no Android app project or build version has not been set to override. Skipping...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':app'.
> Unexpected internal error near index 1
  \

Now this error?

@graknol
Second error is
BUILD FAILED in 12s

Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1
    at ChildProcess.<anonymous> (/Users/runner/runners/2.165.2/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:920:16)
    at Socket.<anonymous> (internal/child_process.js:351:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:509:12)
##[error]Error: /Users/runner/runners/2.165.2/work/1/s/android/gradlew failed with return code: 1

Any guess what it is about?

@abdullah432
Also try replacing this:

def flutterRoot = localProperties.getProperty('flutter.sdk')

with this

def flutterRoot = localProperties.getProperty('flutter.sdk').replaceAll("\\", "/")

When i try again, it start working. First time build run for 2 minutes 7 seconds. Now it giving this error.

! Doctor found issues in 3 categories.
++ pwd
+ echo 'Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter'
Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter
+ flutter build apk --release
Running "flutter pub get" in s...                                   4.3s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                            0.0s
[!] Gradle does not have execution permission.
    You should change the ownership of the project directory to your ***, or move the project to a directory with execute permissions.
Gradle task assembleRelease failed with exit code 1

##[error]The process '/bin/bash' failed with exit code 1
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 1

I think the main problem is solved. Thanks for that. If you can help with above error, it will be appreciated. I think they are building my files in mac machine, This is why these errors are occurring.

Agent name: 'Hosted Agent'
Agent machine name: 'Mac-1357'

@abdullah432
Also try replacing this:

def flutterRoot = localProperties.getProperty('flutter.sdk')

with this

def flutterRoot = localProperties.getProperty('flutter.sdk').replaceAll("\\", "/")

When i try again, it start working. First time build run for 2 minutes 7 seconds. Now it giving this error.

! Doctor found issues in 3 categories.
++ pwd
+ echo 'Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter'
Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter
+ flutter build apk --release
Running "flutter pub get" in s...                                   4.3s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                            0.0s
[!] Gradle does not have execution permission.
    You should change the ownership of the project directory to your ***, or move the project to a directory with execute permissions.
Gradle task assembleRelease failed with exit code 1

##[error]The process '/bin/bash' failed with exit code 1
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 1

I think the main problem is solved. Thanks for that. If you can help with above error, it will be appreciated. I think they are building my files in mac machine, This is why these errors are occurring.

Agent name: 'Hosted Agent'
Agent machine name: 'Mac-1357'

Read about how to chmod folders in linux, it's missing EXECUTE permissions.

The original error is gone yes, you should search for this on stackoverflow.

@abdullah432
Also try replacing this:

def flutterRoot = localProperties.getProperty('flutter.sdk')

with this

def flutterRoot = localProperties.getProperty('flutter.sdk').replaceAll("\\", "/")

When i try again, it start working. First time build run for 2 minutes 7 seconds. Now it giving this error.

! Doctor found issues in 3 categories.
++ pwd
+ echo 'Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter'
Installed flutter to /Users/runner/runners/2.165.2/work/1/s/flutter
+ flutter build apk --release
Running "flutter pub get" in s...                                   4.3s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                            0.0s
[!] Gradle does not have execution permission.
    You should change the ownership of the project directory to your ***, or move the project to a directory with execute permissions.
Gradle task assembleRelease failed with exit code 1

##[error]The process '/bin/bash' failed with exit code 1
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 1

I think the main problem is solved. Thanks for that. If you can help with above error, it will be appreciated. I think they are building my files in mac machine, This is why these errors are occurring.

Agent name: 'Hosted Agent'
Agent machine name: 'Mac-1357'

Read about how to chmod folders in linux, it's missing EXECUTE permissions.

The original error is gone yes, you should search for this on stackoverflow.

Solution for this error here and here is this command chmod a+rx android/gradlew. But this command is not working in window. This error is i think related with mac machine. But i'm trying to solve it, you can give a suggestion. Thanks for the help.

@graknol
I resolve the permission error from this link. After 2 min 17 sec of build same type of error occur again. Before error occur at 32 seconds. A lot progess but ...

FAILURE: Build failed with an exception.
* Where:
Build file '/Users/runner/runners/2.165.2/work/1/s/android/app/build.gradle' line: 9
* What went wrong:
A problem occurred evaluating project ':app'.
> Unexpected internal error near index 1
  \

any news?

I have this issue, and when to add flutter doctor --android-licenses in the script that is needed to answer yes, but I don't know how to respond that.

[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.14.6 18G5033, locale en) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.0) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) [!] Android Studio (not installed) [!] Connected device ! No devices available

Thanks to this all licenses can be accepted by adding this to the script right after setting flutter path:

...
# accepting all licenses
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
...

when will AppCenter support Flutter builds ? We're moving off native to Flutter and need this soon.

Happy to see so many builds working with the addition of the build scripts. We're very curious to hear what services matter to those of you working on Flutter. Where else in App Center would you be looking for Flutter support?

I have tried the flutter appcenter wrappers created for tracking crashes but it hasn't worked. It would be great if there was an offical AppCenter sdk for flutter

@patniko, Any good news?

While i try to build the Android release build using CICD getting below error. It's occurs for the all dependency packages is there any solution. struggled with this issue more than a day.

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/runner/.pub-cache/hosted/pub.dartlang.org/connectivity_macos-0.1.0+3/android/build.gradle' line: 22

  • What went wrong:
    A problem occurred evaluating root project 'connectivity'.

    Failed to apply plugin [id 'com.android.library']
    Minimum supported Gradle version is 5.4.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in /Users/laptop-obs-42/.pub-cache/hosted/pub.dartlang.org/connectivity_macos-0.1.0+3/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.4.1-all.zip

  • 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 18s

Hi! I had the same problem above with the local.properties that was not found on gradle. This is a file generated by flutter when it runs an application.

I found out that I wrote the appcenter-post-clone.sh with misspelling, so, it was not running, then, there was no local.properties or even flutter installed on the AppCenter machine.

After writing it correctly, I had to push to the repo again, open the build configuration on App Center (so it could identify the post clone script) and then Save&Build again.

This is the tutorial I followed and it works if you do it correctly: https://buildflutter.com/deploying-flutter-apps-via-appcenter/

I hope this is helpfull.

Any news?

Is something (hopefully) happen here?

Any updates?

While i try to build the Android release build using CICD getting below error. It's occurs for the all dependency packages is there any solution. struggled with this issue more than a day.

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/runner/.pub-cache/hosted/pub.dartlang.org/connectivity_macos-0.1.0+3/android/build.gradle' line: 22
  • What went wrong:
    A problem occurred evaluating root project 'connectivity'.

Failed to apply plugin [id 'com.android.library']
Minimum supported Gradle version is 5.4.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in /Users/laptop-obs-42/.pub-cache/hosted/pub.dartlang.org/connectivity_macos-0.1.0+3/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.4.1-all.zip

  • 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 18s

@SubashManian Maybe the answear from this question will help you: https://stackoverflow.com/a/63153276/10385430

@darshankawar Thanks for your mention here! I am really stuck with building my flutter app on AppCenter as an iOS app. Any advice would be great!

I need flutter support for Appcenter crashes. Seems like all available flutter package doesn't have trackError capability yet, and I had difficulties using platform channel since I can only pass primitive type, and couldn't find a way to pass Exception/Throwable.

As Flutter is becoming more and more popular and hitting more devices it would be wise to create a flutter plugin for the app center that will be able to use everything the app center has to offer (analytics, crashes, push notifications). The current alternative is Firebase, or modifying iOS/Android project of your app outside of flutter. There are some plugins others developed but they don't maintain it anymore and being Azure, DevOps customer, it would be easy to integrate App center instead of going to mix it with Google and use Firebase....

Don't hold your breath. Microsoft seem to be ignoring Flutter and it's meteoric rise. Go figure.

Official Flutter support would be appreciated!

We need an appcetner-sdk-flutter with official implementation with all the supported Flutter platforms in one Dart Pub Package...

We are mostly a MS dev house starting a large flutter project for UI, can we please get official support?

Official flutter support would be appreciated, otherwise we need to start investigating alternatives.

I agree we really do need official Microsoft support.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriskellor picture chriskellor  ·  3Comments

Oddj0b picture Oddj0b  ·  3Comments

botatoes picture botatoes  ·  4Comments

galfonso777 picture galfonso777  ·  3Comments

sindresorhus picture sindresorhus  ·  3Comments