Skip to content

Commit 574ec59

Browse files
committed
Update to newest version of tools
- robolectric 3.0 - kotlin 1.0.1 - delete espresso tests - collapse into single gradle project
1 parent 46f05d1 commit 574ec59

File tree

23 files changed

+186
-254
lines changed

23 files changed

+186
-254
lines changed

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# Android Example Kotlin
2-
An example of basic Android application setup using Kotlin. It can run Robolectric and Espresso tests.
2+
An example of basic Android application setup using Kotlin, including Robolectric tests.
33

44
This is an example built from the three following sources
55

66
* [Deckard Gradle](https://github.com/robolectric/deckard-gradle) (from the Robolectric team)
7-
demonstrates the base structure for running Robolectric tests and Espresso tests through gradle.
7+
demonstrates the base structure for running Robolectric tests through gradle.
88
* [tests-app-robolectric-junit](https://github.com/blundell/tests-app-robolectric-junit) (by Paul Blundell)
99
demonstrates how to use a components based structure in order to make Robolectric tests well supported by Android Studio.
1010
* [Kotlin Android Tutorial](http://kotlinlang.org/docs/tutorials/kotlin-android.html)
1111
On how to convert the existing Java sctructure to Kotlin.
1212

1313
I haven't done any extra work on making the code nicer using Kotlin.
1414
This project is just a nice minimal starter for any android project using Kotlin and Robolectric.
15+
16+
17+
## Setup
18+
19+
Use Android Studio

application/build.gradle

Lines changed: 0 additions & 35 deletions
This file was deleted.

application/src/androidTest/kotlin/ExampleEspressoTest.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

application/src/main/kotlin/extensions/ButterKnife.kt

Lines changed: 0 additions & 89 deletions
This file was deleted.

application/src/main/kotlin/tasks/Promise.kt

Lines changed: 0 additions & 5 deletions
This file was deleted.

build.gradle

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '0.11.91.4'
2+
ext.kotlin_version = '1.0.1-1'
33

44
repositories {
55
mavenLocal()
@@ -10,13 +10,46 @@ buildscript {
1010
}
1111

1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:1.1.3'
13+
classpath 'com.android.tools.build:gradle:1.5.0'
1414
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1515
}
1616
}
1717

18-
subprojects {
19-
repositories {
20-
mavenCentral()
18+
apply plugin: 'com.android.application'
19+
apply plugin: 'kotlin-android'
20+
21+
repositories {
22+
mavenCentral()
23+
}
24+
25+
android {
26+
compileSdkVersion 23
27+
buildToolsVersion "23.0.3"
28+
29+
defaultConfig {
30+
minSdkVersion 16
31+
targetSdkVersion 23
32+
versionCode 2
33+
versionName "1.0.0-SNAPSHOT"
34+
applicationId "com.example"
2135
}
36+
37+
}
38+
39+
dependencies {
40+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
41+
42+
compile 'com.android.support:support-v4:23.1.1'
43+
compile 'com.android.support:recyclerview-v7:23.1.1'
44+
45+
46+
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
47+
48+
testCompile "junit:junit:4.12"
49+
testCompile "org.hamcrest:hamcrest-core:1.1"
50+
testCompile "org.hamcrest:hamcrest-library:1.1"
51+
testCompile "org.hamcrest:hamcrest-integration:1.1"
52+
53+
testCompile "org.robolectric:robolectric:3.0"
54+
2255
}

local.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
# Location of the SDK. This is only used by Gradle.
88
# For customization when using a Version Control System, please read the
99
# header note.
10-
#Sat May 09 07:27:13 MDT 2015
11-
sdk.dir=/Users/dam5s/Library/Android/sdk
10+
#Thu Mar 24 14:24:26 MDT 2016
11+
sdk.dir=/Users/josephrodriguez/Library/Android/sdk

robolectric-tests/build.gradle

Lines changed: 0 additions & 47 deletions
This file was deleted.

settings.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
rootProject.name = "android-example"
2-
3-
include "application"
4-
include "robolectric-tests"

application/src/main/AndroidManifest.xml renamed to src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
package="com.example">
44

55
<application
6-
android:name=".ExampleApplication"
6+
android:name="com.example.ExampleApplication"
77
android:allowBackup="true">
8-
<activity android:name="com.example.login.LoginActivity" android:screenOrientation="portrait">
8+
<activity android:name=".login.LoginActivity" android:screenOrientation="portrait">
99
<intent-filter>
1010
<action android:name="android.intent.action.MAIN"/>
1111
<category android:name="android.intent.category.LAUNCHER"/>

application/src/main/kotlin/ExampleApplication.kt renamed to src/main/java/com/example/ExampleApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package com.example
22

33
import android.app.Application
44

5-
public class ExampleApplication : Application()
5+
class ExampleApplication : Application()

src/main/java/com/example/Promise.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example
2+
3+
class Promise<T> {
4+
5+
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.example.api
22

3-
import com.example.tasks.Promise
3+
import com.example.Promise
44

5-
trait ApiGateway {
5+
interface ApiGateway {
66
fun <T: ApiResponse> doRequest(request: ApiRequest<T>): Promise<T>
77
}
88

9-
trait ApiRequest<T: ApiResponse> {
9+
interface ApiRequest<T: ApiResponse> {
1010
val method: ApiMethod
1111
val body: Any?
1212

@@ -17,12 +17,12 @@ trait ApiRequest<T: ApiResponse> {
1717
fun buildResponse(): T
1818
}
1919

20-
trait ApiResponse {
20+
interface ApiResponse {
2121
}
2222

2323
enum class ApiMethod {
24-
GET
25-
POST
26-
PUT
24+
GET,
25+
POST,
26+
PUT,
2727
DELETE
2828
}

application/src/main/kotlin/api/HttpApiGateway.kt renamed to src/main/java/com/example/api/HttpApiGateway.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.api
22

3-
import com.example.tasks.Promise
3+
import com.example.Promise
44

55
class HttpApiGateway: ApiGateway {
66
override fun <T : ApiResponse> doRequest(request: ApiRequest<T>): Promise<T> {

0 commit comments

Comments
 (0)