Merge pull request #1305 from nextcloud/updatzeKlint

[no-ci] Update ktlint formatter + documenting update steps
This commit is contained in:
Andy Scherzinger 2021-06-08 23:05:09 +02:00 committed by GitHub
commit 4d8e70840c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 40 deletions

View file

@ -56,7 +56,7 @@
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" static="false" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
@ -212,7 +212,8 @@
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>

117
SETUP.md
View file

@ -1,16 +1,39 @@
These instructions will help you to set up your development environment, get the source code of the Nextcloud Talk for Android app and build it by yourself. If you want to help developing the app take a look to the [contribution guidelines][0].
# [Nextcloud](https://nextcloud.com) Talk for Android Setup Guide
Sections 1) and 2) are common for any environment. The rest of the sections describe how to set up a project in different tool environments. Nowadays we recommend to use Android Studio (section 2), but you can also build the app from the command line (section 3).
# Index
1. [Setup Guide](#setup-guide)
1. [Tooling setup](#tooling-setup)
1. [Fork and checkout the repository](#fork-and-checkout-the-repository)
1. [Work and build environments](#work-and-build-environments)
1. [Working with Android Studio](#working-with-android-studio)
1. [Working in a terminal with gradle](#working-in-a-terminal-with-gradle)
1. [App flavours](#app-flavours)
1. [Update Android Studio ktlint formatter](#update-android-studio-ktlint-formatter)
1. [Troubleshooting](#troubleshooting)
1. [Compilation fails with "java.lang.OutOfMemoryError: Java heap space" error](#compilation-fails-with-javalangoutofmemoryerror-java-heap-space-error)
If you have any problem, remove the 'talk-android' folder, start again from 1) and work your way down. If something still does not work as described here, please open a new issue describing exactly what you did, what happened, and what should have happened.
# Setup Guide
### 0. Common software dependencies.
These instructions will help you to set up your development environment, get the source code of the Nextcloud Talk for Android app and build it by yourself.
If you want to help developing the app take a look to the [contribution guidelines][0].
Sections 1) and 2) are common for any environment.
The rest of the sections describe how to set up a project in different tool environments.
Nowadays we recommend to use Android Studio (section 2), but you can also build the app from the command line (section 3).
If you have any problem, remove the 'talk-android' folder, start again from 1) and work your way down.
If something still does not work as described here, please open a new issue describing exactly what you did, what happened, and what should have happened.
## Tooling setup
There are some tools needed, no matter what is your specific IDE or build tool of preference.
[git][1] is used to access to the different versions of the Nextcloud's source code. Download and install the version appropriate for your operating system from [here][2]. Add the full path to the 'bin/' directory from your git installation into the PATH variable of your environment so that it can be used from any location.
[git][1] is used to access to the different versions of the Nextcloud's source code.
Download and install the version appropriate for your operating system from [here][2].
Add the full path to the 'bin/' directory from your git installation into the PATH variable of your environment so that it can be used from any location.
[Android Studio][5] is currently the official Android IDE. Due to this, we recommend it as the IDE to use in your development environment. Follow the installation instructions [here][6].
[Android Studio][5] is currently the official Android IDE. Due to this, we recommend it as the IDE to use in your development environment.
Follow the installation instructions [here][6].
We recommend to use the last version available in the stable channel of Android Studio updates.
@ -34,49 +57,74 @@ Install any other package you consider interesting, such as emulators.
After installing it, add the full path to the directories 'tools/' and 'platform-tools/' from your Android SDK installation into the PATH variable of your environment.
### 1. Fork and download the nextcloud/talk-android repository.
## Fork and checkout the repository
You will need [git][1] to access to the different versions of the Nextcloud's source code. The source code is hosted on GitHub and may be read by anybody, without a GitHub account. You will need one if you want to contribute to the development of the app with your own code.
Fork and download the nextcloud/talk-android repository.
You will need [git][1] to access to the different versions of the Nextcloud's source code.
The source code is hosted on GitHub and may be read by anybody, without a GitHub account.
You will need one if you want to contribute to the development of the app with your own code.
The next steps will assume you have a GitHub account and that you will get the code from your own fork.
* In a web browser, go to https://github.com/nextcloud/talk-android, and click the 'Fork' button near the top right corner.
* Open a terminal and go on with the next steps in it.
* Clone your forked repository: ```git clone --recursive https://github.com/YOURGITHUBNAME/talk-android.git```.
* Move to the project folder with ```cd talk-android```.
* Pull any changes from your remote branch 'master': ```git pull origin master```
* Make official Nextcloud repo known as upstream: ```git remote add upstream https://github.com/nextcloud/talk-android.git```
* Make sure to get the latest changes from official talk-android/master branch: ```git pull upstream master```
1. In a web browser, go to https://github.com/nextcloud/talk-android, and click the 'Fork' button near the top right corner.
2. Open a terminal and go on with the next steps in it.
3. Clone your forked repository: ```git clone --recursive https://github.com/YOURGITHUBNAME/talk-android.git```.
4. Move to the project folder with ```cd talk-android```.
5. Pull any changes from your remote branch 'master': ```git pull origin master```
6. Make official Nextcloud repo known as upstream: ```git remote add upstream https://github.com/nextcloud/talk-android.git```
7. Make sure to get the latest changes from official talk-android/master branch: ```git pull upstream master```
At this point you can continue using different tools to build the project. Section 2 and 3 describe the existing alternatives.
At this point you can continue using different tools to build the project.
Sections [Working with Android Studio](#working-with-android-studio) and [Working in a terminal with gradle](#working-in-a-terminal-with-gradle) describe the existing alternatives.
### 2. Working with Android Studio.
## Work and build environments
### Working with Android Studio
To set up the project in Android Studio follow the next steps:
* Open Android Studio and select 'Open an Existing Project'. Browse through your file system to the folder 'talk-android' where the project is located. The file chooser will show an Android face as the folder icon, which you can select to reopen the project.
* Android Studio will try to build the project directly after importing it. To build it manually, just click the 'Play' button in the toolbar to build and run it in a mobile device or an emulator. The resulting APK file will be saved in the 'app/build/outputs/apk/' subdirectory in the project folder and being installed/launched in a configured emulator or if connected your physical device.
* Check Android Studio editor configuration for the project: ```Settings``` → ```Editor``` → ```Code Style``` → ```Scheme: Project``` and ```Enable EditorConfig support``` (should be enabled by default)
1. Open Android Studio and select 'Open an Existing Project'. Browse through your file system to the folder 'talk-android' where the project is located. The file chooser will show an Android face as the folder icon, which you can select to reopen the project.
2. Android Studio will try to build the project directly after importing it. To build it manually, just click the 'Play' button in the toolbar to build and run it in a mobile device or an emulator. The resulting APK file will be saved in the 'app/build/outputs/apk/' subdirectory in the project folder and being installed/launched in a configured emulator or if connected your physical device.
3. Check Android Studio editor configuration for the project: ```Settings``` → ```Editor``` → ```Code Style``` → ```Scheme: Project``` and ```Enable EditorConfig support``` (should be enabled by default)
### 3. Working in a terminal with Gradle:
### Working in a terminal with gradle
[Gradle][7] is the build system used by Android Studio to manage the building operations on Android apps. You do not need to install Gradle in your system, and Google recommends not to do it, but instead trusting on the [Gradle wrapper][8] included in the project.
[Gradle][7] is the build system used by Android Studio to manage the building operations on Android apps.
You do not need to install gradle in your system, and Google recommends not to do it, but instead trusting on the [Gradle wrapper][8] included in the project.
* Open a terminal and go to the 'talk-android' directory that contains the repository.
* Run the 'clean' and 'build' tasks using the Gradle wrapper provided
1. Open a terminal and go to the 'talk-android' directory that contains the repository.
2. Run the 'clean' and 'build' tasks using the gradle wrapper provided
- Windows: ```gradlew.bat clean assembleGplay``` or ```gradlew.bat clean assembleGeneric```
- Mac OS/Linux: ```./gradlew clean assembleGplay``` or ```./gradlew clean assembleGeneric```
The first time the Gradle wrapper is called, the correct Gradle version will be downloaded automatically. This requires a working Internet connection.
The first time the gradle wrapper is called, the correct gradle version will be downloaded automatically.
This requires a working Internet connection.
The generated APK file is saved in app/build/outputs/apk as app-generic-debug.apk
The generated APK file is saved in ```app/build/outputs/apk``` as ```app-generic-debug.apk```.
### 4. App flavours
### App flavours
The app is currently equipped to be built with three flavours:
* Generic - the regular build, released as Nextcloud Android app on F-Droid
* Gplay - with Google Stuff (Push notification), used for Google Play Store
* Qa - Build per pr for testing
* **Generic** - the regular build, released as Nextcloud Android app on F-Droid
* **Gplay** - with Google stuff (push notification), used for Google Play store
* **Qa** - build per pr for testing
### Update Android Studio ktlint formatter
To update the formatter rules for kotlin files:
1. Download [latest release][9] to project's root folder
2. Run the following command: ```java -jar ktlint --android applyToIDEAProject -y```
3. Diff the changed files and incorporate the updates/changes only. This needs to be done by hand since the Android Studio files contain formatting rules for java and xml as well which are overridden (as in removed) by the ktlint generator.
## Troubleshooting
### Compilation fails with "java.lang.OutOfMemoryError: Java heap space" error
The default settings for gradle is to limit the compilation to 1GB of heap.
You can increase that value by:
1. adding `org.gradle.jvmargs=-Xmx4G` to `gradle.properties` and
2. running gradlew(.bat) with this command line : `GRADLE_OPTS="-Xmx4G" ./gradlew clean build"`
[0]: https://github.com/nextcloud/talk-android/blob/master/CONTRIBUTING.md
[1]: https://git-scm.com/
@ -85,11 +133,4 @@ The app is currently equipped to be built with three flavours:
[6]: https://developer.android.com/studio/install
[7]: https://gradle.org/
[8]: https://docs.gradle.org/current/userguide/gradle_wrapper.html
### 5. Troubleshooting
#### 1. Compilation fails with "java.lang.OutOfMemoryError: Java heap space" error
The default settings for Gradle is to limit the compilation to 1GB of heap.
You can increase that value by :
- adding `org.gradle.jvmargs=-Xmx4G` to `gradle.properties`
- running gradlew(.bat) with this command line : `GRADLE_OPTS="-Xmx4G" ./gradlew clean build"
[9]: https://github.com/pinterest/ktlint/releases/latest