Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build "e2e" release Android using flavors #3837

Closed
alexborton opened this issue Jan 12, 2023 · 2 comments
Closed

Build "e2e" release Android using flavors #3837

alexborton opened this issue Jan 12, 2023 · 2 comments

Comments

@alexborton
Copy link

Description

We want to be able to run our Detox e2e tests locally, but as a release build (or as close as we can get). The problem i am struggling with is using a flavor to set this up, in order to avoid signing with a real signing certificate. On CI, the certificate will be available, but for security, we don't keep that locally.

As an example, our flavor setup in build.gradle might look something like this;

    signingConfigs {
        release {
            keyAlias '..'
            keyPassword ...
            storeFile ..
            storePassword ...
        }
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }        
    }

...

    buildTypes {
        release {
            // no signing specified on the build type...
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

...

productFlavors {
        // dev {
            
        // }
        prod {
           // signing for prod specified as release
            signingConfig signingConfigs.release
        }
        e2e {
            // signing for e2e flavor specified as debug
            signingConfig signingConfigs.debug
        }
        ...
    }

Finally, the detox config could look like;

    "android.release": {
      "type": "android.apk",
      // the output will be slightly different, but not relevant to question
      "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
      "build": "cd android && ./gradlew assembleE2eRelease assembleAndroidTest -DtestBuildType=release && cd .."
    }

Unfortunately, this approach does not work. It seems to be ignoring the signing setup for the flavor, possibly specifically around the assembleAndroidTest, but i'm not sure. The following error presents;

> Task :app:packageProdReleaseAndroidTest FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:packageProdReleaseAndroidTest' (type 'PackageApplication').
  - In plugin 'com.android.internal.version-check' type 'com.android.build.gradle.tasks.PackageApplication' property 'signingConfigData.signingConfigData.storeFile' specifies file '/Users/aborton/Code/Account.NativeApp/android/secure/**.jks' which doesn't exist.
    
    Reason: An input file was expected to be present but it doesn't exist.
    
    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.

It's correct, the .jks file it's looking for is not present, but as far as i am concerned, it shouldn't be looking for it.

There is likely a clue here; packageProdReleaseAndroidTest but i can't see why it would try to construct that? prod being a flavor and release being the buildType.

Your environment

Detox version: 20.1.1
React Native version: 0.70.6
Node version:
Device model:
OS:
Test-runner (select one): jest

@d4vidi
Copy link
Collaborator

d4vidi commented Jan 12, 2023

@alexborton Apologies, but I'm not sure how to help here. Might be a good idea to put this out there on Stackoverflow / Discord, instead.

One thing that it might make sense to do is to look for a more specific alternative to running the fully blown assembleAndroidTest gradle task. Likely, you should have something such as assembleE2EAndroidTest available.

@github-actions
Copy link

This issue appears to be a general usage or support question.
In order to get help, please either ask a question on Stack Overflow with the detox tag, or simply join our Discord.
Feel free to post your Stack Overflow question here for more visibility!
For more information about our policy on issues, refer to this discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants