mmcc007 / sylph

Runs Flutter integration tests on real devices in cloud.
GNU General Public License v3.0
157 stars 43 forks source link

Cannot use sylph with flavors #75

Closed Vanethos closed 4 years ago

Vanethos commented 4 years ago

If sylph is run in an app with falvors, the following occurs:

Starting Flutter app com.ianum.app
.dev
.alpha in debug mode...
Running "flutter pub get" in ianum_flutter...                       0.8s
Android Debug Bridge version 1.0.41
Version 29.0.1-5644136
Installed as /Users/goncalopalma/Library/Android/sdk/platform-tools/adb
/system/bin/sh: .dev: not found
/system/bin/sh: .alpha: not found

As you can see from the multiple lines it went to fetch not only applicationId but also applicationIdSuffix

Additionally, the project assumes in adb shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true "$app_id/$app_id.MainActivity"

That all applicatuons will:

This will throw an error since adb will not be able to find that activity

Vanethos commented 4 years ago

PR #76 attempts to fix this

mmcc007 commented 4 years ago

Added fix for this on android only and tested on device farm. Will add iOS support later. Please try testing with your app or with:

git clone https://github.com/mmcc007/sylph.git
cd sylph
git checkout #75_flavors
pub global activate --path source .
cd example/flavors
sylph

Didn't run into the problem with 'app id/package name' using the example/flavors app. So let me know if you do with your app.

Feel free to merge with your PR.

Vanethos commented 4 years ago

Hi @mmcc007

Yes, I do have the problem of the app Id being different than the package name

I'm sorry to ask this, but is there a problem with the code in the PR? I spent some days trying to understand the code and finding a good way to be as concise and as clean as possible, so if there is something wrong with it, I would be very grateful since it is also a learning opportunity for me. Else it feels like I wasted all those hours for nothing

Vanethos commented 4 years ago

As for the app id vs package name

You have the same package name: com/example/example/ as the app id: applicationId "com.example.example"

If for example you had applicationId "com.sylph.test"

So, when calling sylph, this line of code:

adb shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true "$app_id/$app_id.MainActivity"

Would try to call com.sylph.test/com.sylph.test.MainActivity which would incurr an error

My PR lets you specify a package name, com.example.ecample, so that the same code can call

com.sylph.test/com.example.example.MainActivity.

Also, since you specify the app id, you don't have to search for all the possible app suffixes or prefixes in gradle, since you can have a different application id for each flavor (I have worked in some projects like this), which is why it is vital to specify it in the sylph.yaml file

mmcc007 commented 4 years ago

Sorry for the separate branch. It was a convenient way to try to reproduce the problem and add some code. I will merge to your PR as appropriate (now that I know how to merge to PRs 😆). Thanks for your contribution.

Not super familiar with flavors. Seems like there is more than one way to config flavors (for android and ios). Is it possible to add an example to the example directory that shows how you are configuring for flavors? That way, I can get up to speed with what you are running into.

Vanethos commented 4 years ago

No, no problem!

It's just that I assumed that there is something wrong with my code, and to be honest I would love to learn what it is, since well... I learned bash to help out with this PR ahaha

As for the flavors, this weekend I'll see if I have time to add a "flavored" example, but basically it consists of:

As for iOS, I went through the bash scripts and the ruby scripts and I think that it's all okay.

Tested it with Android on AWS and the tests were successful

mmcc007 commented 4 years ago

Great!

Added a flavor example to your PR I found in https://github.com/flutter/flutter/tree/master/dev/integration_tests/flavors that works on #75_flavors branch for android (and almost for iOS). Will test if it works on your PR (prob tomorrow).

mmcc007 commented 4 years ago

BTW: I can run example/flavors locally using test_android.sh. So looks good that it will run on AWS.

Vanethos commented 4 years ago

@mmcc007 I think I went through the iOS files stuff and I think that there should no problem with the flavors in iOS:

mmcc007 commented 4 years ago

Not sure if I understand correctly (not an expert on android intents). Does this mean your current handling of the call to the android intent may change?

Regarding iOS, based on testing on #75_flavors yesterday on example/flavors, it's getting as far as starting the test and running into a build issue related to building the wrong flavor (which should be fixable). So remains to be seen if any additional handling is required to run a flavor test on iOS. Will run same iOS test on your PR and see what happens.

mmcc007 commented 4 years ago

I ran test on example/flavors for android on AWS and it succeeded. So that's a good thing.

Might do some experimentation of handling of intent (locally) to learn more about how intents behave.

MarcoAltranDC commented 4 years ago

I get the error below whether I run using

git clone https://github.com/mmcc007/sylph.git cd sylph git checkout #75_flavors pub global activate --path source . cd example/flavors sylph

or if I am in master.

image

mmcc007 commented 4 years ago

@MarcoAltranDC I was able to reproduce this problem on android. I will look into it.

I confirmed it continues to work on iOS. So for the meantime, if on a mac, run on an iOS pool only.

parentivapp commented 4 years ago

@mmcc007 any timeline when this will be fixed? I am unable to test my app due to this. Thanks.

ManmeetChadha9 commented 4 years ago

@mmcc007 , just wanted to know if we can get the Android fix, anytime soon... ?

mmcc007 commented 4 years ago

Updated the reference flavor app (for androidx and latest XCode) and ran a test concurrently for android and ios (see https://travis-ci.com/mmcc007/sylph/jobs/292532712).

The reference flavor app is the currently supported and recommended way to implement flavors (taken from Flutter). There are other ways to implement flavors which may work in an CI/CD environment, but are not currently supported (in interests of simplicity).

Resources available to support other flavors implementations are limited. If alternate flavors implementations don't run on sylph, please open another issue and ideally provide a link to source code to reproduce problem.