-
Notifications
You must be signed in to change notification settings - Fork 2
Green Annotations Wiki
Maven is used as the build-system and must be installed: see Apache Maven Installation
The project can also be built without Android SDK, but the Android SDK is required to run the tests.
- see Android Studio - Download options - Get just the command line tools
- SDK build tools
- API 17: SDK
- the
ANDROID_HOME
environment variable must be set
- build and install with tests:
mvn install
- build and install without tests:
mvn -Dmaven.test.skip=true install
IntelliJ has built in Maven support, so you can just import the Maven project (Hint: select the root directory, where the top-most pom.xml
file is located).
The Maven import already does most of the setup, but there are some settings, that we need to adjust after the project import.
-
Project Structure
-
Platform Settings
-
SDKs: check that you have a valid JAVA SDK and a valid Android SDK for platform 17. If not, add them.
IMPORTANT: after adding the Android SDK, you may need to restart the IDE see Stackoverflow: I can't get IntelliJ to recognise my Android SDK
-
SDKs: check that you have a valid JAVA SDK and a valid Android SDK for platform 17. If not, add them.
-
Platform Settings
-
Project
- set the default Project SDK to a Java 1.8 SDK
- set the Project language level to:
7 - Diamonds, ARM, multi-catch etc.
-
Facets
-
Android (green-annotations-test)
-
Structure
-
Manifest file: correct the path to reference the
AndroidManifest.xml
file insrc/main
-
Resources directory: correct the path to reference the
res
directory insrc/main
-
Manifest file: correct the path to reference the
-
Maven: deactivate the following check-boxes, so that our changes in the Structure tab-sheet will not get overwritten when we re-import the configuration from the maven
pom.xml
files- Manifest file path
- Resources directory path
-
Structure
-
Android (green-annotations-test)
now Build - Make Project should already work
- open a test file: e.g.
green-annotations-test/src/test/java/com/tmtron/greenannotations/test/GreenEventBusActivityTest.java
- click Run - Run to execute the JUnit test
- when you see a window with 2 options, select the one at the bottom (with the 2 red/green arrows)
- when you see this error:
!!! JUnit version 3.8 or later expected
you have to move the JUnit dependency before the Android dependency:- open File - Project Structure - Project Settings - Modules
- select green-annotations-test
- go to the Dependencies tab-sheet
- move the JUnit dependency (
Maven: junit:junit:4.12
) to the very top (even beforeMaven Android API 17 Platform
) - see http://stackoverflow.com/a/2431427/6287240
- Open the Maven projects view: View - Tool Windows - Maven Projects
- Open the Lifecycle node of an of the maven projects and then just double click any of the lifecycle events
When you update the SDK tools, it may fail and leave you with an empty $ANDROID_HOME/tools
directory:
see Stackoverflow: Updating Android SDK: “A folder failed to be moved.”
This seems to depend on the order of the dependencies: when the Android SDK
dependency comes after Maven: org.androidannotations:androidannotations:4.1.0
then androidannotations-annotation processor is not run and the generated sources are missing.