Skip to content

Commit

Permalink
android build: Update Gradle to 6.0.1.
Browse files Browse the repository at this point in the history
Part of the RN v0.61 -> v0.62 changes to the template app [2],
corresponding to the following commits:

- facebook/react-native@be2a2529a
- facebook/react-native@b1c954b1f
- facebook/react-native@ff6b2ff32
- facebook/react-native@928f4434b
- facebook/react-native@701e66bde

Probably best to do this before the main upgrade commit.

We treat this as an upgrade from 5.5.x to the latest 5.6.x (which is
the latest 5.x), and then to 6.0.1 (the latest 6.0.x). [1]

- facebook/react-native@be2a2529a also added some comments in
  gradle.properties, which we reproduce.

- We ran into a couple of different build failures, so, add those to
  the troubleshooting doc with the cache-clearing commands that
  worked to resolve them (from SO [3]).

Release notes from Gradle upstream:
  https://docs.gradle.org/5.6.4/release-notes.html
  https://docs.gradle.org/6.0.1/release-notes.html

Upgrade guides:
  https://docs.gradle.org/5.6.4/userguide/upgrading_version_5.html#changes_5.6.4
  https://docs.gradle.org/6.0.1/userguide/upgrading_version_5.html#changes_6.0.1

We didn't spot any deprecations or announced breaking changes as
applying to us, though it's a bit hard to tell (in particular, we
use plenty of Gradle code that isn't ours, so we wouldn't
necessarily spot something). We hope we'd catch any by just trying
the build, e.g., with `tools/test android --full`.

The upgrade guides recommend a "build scan", which we did by running
`./gradlew help --scan`. In particular, the upgrade guides ask that
you find a "Deprecations" section in the left nav of a web page
showing the result of the scan.

The build scan report at v5.6.4 [4] doesn't have a "Deprecations"
section. This might mean that the feature was missing at that
version, or it might mean that it looked for deprecations expressed
in a certain way [5] and didn't find any.

The report at v6.0.1 [6] did have a "Deprecations" section, with the
following two warnings:

"""
BuildListener#buildStarted(Gradle) has been deprecated.
This is scheduled to be removed in Gradle 7.0.
32 usages

The maven plugin has been deprecated.
This is scheduled to be removed in Gradle 7.0.
Please use the maven-publish plugin instead.
19 usages
"""

Expanding the 32 usages in the first of these, all but one are in
the `com.android.library` plugin; one is in the `android` plugin.

Expanding the 19 usages in the second of these, they're all in the
`org.gradle.maven` plugin.

In the console output from the build-scan command at both versions
(shown in the build scan reports) we see some deprecation warnings
from the Android Gradle Plugin, rather than Gradle itself. They
apply to three of our dependencies, and we have issues to replace
those dependencies (two of the issues filed just now):

- `react-native-photo-view`; see zulip#4217
- `react-native-text-input-reset`; see zulip#4239
- `react-native-device-info`; see zulip#4240

[1] See discussion around
    zulip#4244 (comment)
    for some nuances about this.

[2] https://react-native-community.github.io/upgrade-helper/?from=0.61.5&to=0.62.2

[3] https://stackoverflow.com/a/62025502

[4] https://gradle.com/s/2szkm2hvdrejy. The build scan at this link
    will be "available indefinitely", according to
    https://scans.gradle.com/.

[5] zulip#4244 (comment)

[6] https://scans.gradle.com/s/l7q26kntclub6
  • Loading branch information
chrisbobbe committed Sep 11, 2020
1 parent 73276d9 commit 2c42511
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
6 changes: 5 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.enableJetifier=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# $ ./gradlew wrapper --distribution-type=all --gradle-version=NEW_VERSION
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down
2 changes: 1 addition & 1 deletion android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
27 changes: 27 additions & 0 deletions docs/howto/build-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,33 @@ To fix the problem, run `yarn`, which will update your installed
packages in `node_modules/` to match the current `package.json`. You
might need to restart Metro / `react-native start` after doing so.

### Build failure: java.nio.file.NoSuchFileException: /Users/chrisbobbe/dev/zulip-mobile/android/app/build/intermediates/

When trying to build the Android app, you may see this error:

```
java.nio.file.NoSuchFileException: /Users/chrisbobbe/dev/zulip-mobile/android/app/build/intermediates/external_file_lib_dex_archives/debug/out
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:407)
```

Try removing `android/.gradle`, running `./gradlew clean` from
`android/`, and building again.

### Build failure: No file known for: classes.dex

When trying to build the Android app, you may see this error:

```
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> No file known for: classes.dex
```

Try removing `android/.gradle`, running `./gradlew clean` from
`android/`, and building again.

### Build failure: java.lang.UnsupportedClassVersionError, "Unsupported major.minor version 52.0"

Expand Down

0 comments on commit 2c42511

Please sign in to comment.