hanabi1224 / flutter_appcenter_bundle

MIT License
21 stars 48 forks source link

AppCenter build #38

Open Dooks123 opened 3 years ago

Dooks123 commented 3 years ago

Hi, I have an issue where I can't get the flutter app to build with flutter_appcenter_bundle-3.3.1+2 on https://appcenter.ms

When testing locally with Gradle Plugin < 4.0.0 I get an error with isDefault:

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method isDefault() for arguments [true] on ProductFlavor_Decorated{name=appCenter,...

Excerpt from flutter_appcenter_bundle-3.3.1+2\android\build.gradle

flavorDimensions "distribute"
    productFlavors {
        appCenter {
            dimension "distribute"
        }
        googlePlay {
            isDefault true <-- Only works with gradle plugin 4.0.0+
            dimension "distribute"
        }
    }

However without the library, it builds on Gradle Plugin 3.5.0 and 3.6.4 and builds successfully on https://appcenter.ms

When changing to Gradle plugin 4.0.0 that error disappears locally and the build succeeds

BUT...

on https://appcenter.ms I get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalAppCenterRelease'.
> Could not resolve all artifacts for configuration ':app:appCenterDebugRuntimeClasspath'.
   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /Users/runner/work/1/s/build/app/intermediates/flutter/appCenterDebug/libs.jar.
         > Failed to transform '/Users/runner/work/1/s/build/app/intermediates/flutter/appCenterDebug/libs.jar' using Jetifier. Reason: FileNotFoundException, message: /Users/runner/work/1/s/build/app/intermediates/flutter/appCenterDebug/libs.jar (No such file or directory). (Run with --stacktrace for more details.)
       Please file a bug at http://issuetracker.google.com/issues/new?component=460323.

Now all of a sudden on https://appcenter.ms, Gradle Plugin 4+ wants to have .../intermediates/flutter/appCenterDebug/libs.jar' available to be able to build successfully.

But it will never work, because right after the flutter script ran (copy of the script here: sample-build-scripts/flutter/android-build/appcenter-post-clone.sh) it runs the normal gradlew again:

[command]/Users/runner/work/1/s/android/gradlew -DAPPCENTER_BUILD_VERSION=64 -DMOBILECENTER_BUILD_VERSION=64 -p android clean :app:assembleAppCenterRelease :app:lintAppCenterRelease

Notice the clean in the command, it deletes the intermediates folder and only builds :app:assembleAppCenterRelease :app:lintAppCenterRelease

So it doesn't matter if I build --debug and --release in the flutter script, it will still clear that folder and break like this.

So how do I get https://appcenter.ms to build the flutter app with this library included?

I have had no luck at this at all and been sitting with this for days now. I have asked on StackOverflow as well:

https://stackoverflow.com/questions/67278979/flutter-appcenter-flavor-build-issue

any help would be appreciated.

Dooks123 commented 3 years ago

@hanabi1224 Is it totally necessary to use Gradle plugin 4.0.0+ or can it still work with 3.6.4 (without the isDefault)?

hanabi1224 commented 3 years ago

Sorry but I have to say it's out of scope to test and ensure appcenter cloud build success since flutter is involving fast and also AFAIK cloud build for flutter is not even official supported. Any working solutions are 'hacky workaround', and tend to be broken as flutter involves.

So the best I can say for now is good luck but contributions are always welcome.

Dooks123 commented 3 years ago

@hanabi1224 Currently the best way to build the app is via Azure Devops Build Pipelines and distribute it to AppCenter (Works excellent for both Android and iOS builds).

Unless someone can find a way to remove the clean argument within gradlew like I posted here (but it is hacky as you say)