Gitlab-ci.yml integration with react native android

Hi, so I’m trying to add CI in my react native project, but facing error sharing the gitlab-ci.yml file along with error, help pls.

gitlab-ci.yml

image: reactnativecommunity/react-native-android

before_script:

  • export ANDROID_SDK_ROOT=$ANDROID_HOME
  • export GRADLE_USER_HOME=$(pwd)/.gradle
  • npx envinfo
  • npm install

stages:

  • build
  • test
  • deploy

build:
stage: build
script:
- echo $CI_COMMIT_TAG
- cd android && chmod +x gradlew
- ./gradlew clean
- ./gradlew assembleRelease

when: manual

artifacts:
paths:
- android/app/build/outputs/

test:
stage: test
script:
- echo “Testing the app”
when: manual

deploy:
stage: deploy
script:

  • sudo gem install fastlane
  • sudo gem install bundler -v 2.4.22
  • sudo bundle install
  • fastlane deploy

when: manual

error:

location: class RNPlayServicesLocationProvider

Note: Some input files use or override a deprecated API.

FAILURE: Build failed with an exception.

What went wrong:

3496Execution failed for task ‘:react-native-location:compileReleaseJavaWithJavac’.

Hi,

Firstly, please format your posts in the future, as described here: Community, first steps: Code, config, log block formatting in topics and replies

Secondly, this looks to me like a generic build issue, related to Android / Gradle build and has nothing to do with GitLab. You should google the error and see why is it coming up (if the build works locally of course, otherwise you cannot expect for it to work in CI either).

Also, what I would suggest you is to pin the version of the image you’re using: reactnativecommunity/react-native-android means it will always grab “latest” which is quite unstable and from my experience, Gradle is super sensitive about SDK changes. So make sure you are using the correct SDK version here. Available tags you can always find on project’s pages / DockerHub.

Well I’m still looking for the root cause but running npx jetify fixed it for me. Anyway thanks for the help.