aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAng Li <angli@google.com>2019-01-28 21:33:17 -0800
committerGitHub <noreply@github.com>2019-01-28 21:33:17 -0800
commit6486fbb0e93f21a3657e8a1f5660e035b51fe333 (patch)
tree3e1010992ebf56566da24a9e418da5631b6bd62d
parenta337f516cdce2882bb2a9661229f92a14d898fe3 (diff)
downloadmobly-snippet-lib-6486fbb0e93f21a3657e8a1f5660e035b51fe333.tar.gz
Fix examples. (#102)
* Fix ex2 and ex4 builds * Update unsupported target SDK version. * Update usage of deprecated API of instrumentation registry. * Update apk path in tutorial.
-rw-r--r--examples/ex1_standalone_app/build.gradle2
-rw-r--r--examples/ex2_espresso/README.md2
-rw-r--r--examples/ex2_espresso/build.gradle1
-rw-r--r--examples/ex2_espresso/src/snippet/AndroidManifest.xml3
-rw-r--r--examples/ex3_async_event/build.gradle2
-rw-r--r--examples/ex4_uiautomator/build.gradle5
-rw-r--r--examples/ex4_uiautomator/src/main/java/com/google/android/mobly/snippet/example4/UiAutomatorSnippet.java5
-rw-r--r--examples/ex5_schedule_rpc/build.gradle2
-rw-r--r--third_party/sl4a/build.gradle2
9 files changed, 13 insertions, 11 deletions
diff --git a/examples/ex1_standalone_app/build.gradle b/examples/ex1_standalone_app/build.gradle
index 1825c7e..eed268a 100644
--- a/examples/ex1_standalone_app/build.gradle
+++ b/examples/ex1_standalone_app/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.google.android.mobly.snippet.example1"
minSdkVersion 15
- targetSdkVersion 22
+ targetSdkVersion 26
versionCode 1
versionName "0.0.1"
}
diff --git a/examples/ex2_espresso/README.md b/examples/ex2_espresso/README.md
index 03973d1..b43507a 100644
--- a/examples/ex2_espresso/README.md
+++ b/examples/ex2_espresso/README.md
@@ -111,7 +111,7 @@ to automate a simple app.
1. Install the apk on your phone
- adb install -r ./examples/ex2_espresso/build/outputs/apk/debug/ex2_espresso-snippet-debug.apk
+ adb install -r ./examples/ex2_espresso/build/outputs/apk/snippet/debug/ex2_espresso-snippet-debug.apk
1. Use `snippet_shell` from mobly to trigger `pushMainButton()`:
diff --git a/examples/ex2_espresso/build.gradle b/examples/ex2_espresso/build.gradle
index 64dcdc6..9caf136 100644
--- a/examples/ex2_espresso/build.gradle
+++ b/examples/ex2_espresso/build.gradle
@@ -18,6 +18,7 @@ android {
dimension "examples"
}
snippet {
+ testApplicationId "com.google.android.mobly.snippet.example2.snippet"
dimension "examples"
}
}
diff --git a/examples/ex2_espresso/src/snippet/AndroidManifest.xml b/examples/ex2_espresso/src/snippet/AndroidManifest.xml
index 95ee221..85797ce 100644
--- a/examples/ex2_espresso/src/snippet/AndroidManifest.xml
+++ b/examples/ex2_espresso/src/snippet/AndroidManifest.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.android.mobly.snippet.example2.snippet">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data
diff --git a/examples/ex3_async_event/build.gradle b/examples/ex3_async_event/build.gradle
index b463565..24e6dff 100644
--- a/examples/ex3_async_event/build.gradle
+++ b/examples/ex3_async_event/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.google.android.mobly.snippet.example3"
minSdkVersion 15
- targetSdkVersion 22
+ targetSdkVersion 26
versionCode 1
versionName "0.0.1"
}
diff --git a/examples/ex4_uiautomator/build.gradle b/examples/ex4_uiautomator/build.gradle
index cd160be..9b4bbe6 100644
--- a/examples/ex4_uiautomator/build.gradle
+++ b/examples/ex4_uiautomator/build.gradle
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
+ // This has to match what the appcompat dep expects.
+ compileSdkVersion 28
defaultConfig {
applicationId "com.google.android.mobly.snippet.example4"
minSdkVersion 18
- targetSdkVersion 22
+ targetSdkVersion 26
versionCode 1
versionName "0.0.2"
}
diff --git a/examples/ex4_uiautomator/src/main/java/com/google/android/mobly/snippet/example4/UiAutomatorSnippet.java b/examples/ex4_uiautomator/src/main/java/com/google/android/mobly/snippet/example4/UiAutomatorSnippet.java
index 288d1bd..9fc01b2 100644
--- a/examples/ex4_uiautomator/src/main/java/com/google/android/mobly/snippet/example4/UiAutomatorSnippet.java
+++ b/examples/ex4_uiautomator/src/main/java/com/google/android/mobly/snippet/example4/UiAutomatorSnippet.java
@@ -20,7 +20,8 @@ import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.content.Intent;
-import androidx.test.InstrumentationRegistry;
+
+import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
@@ -53,7 +54,7 @@ public class UiAutomatorSnippet implements Snippet {
private final UiDevice mDevice;
public UiAutomatorSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
}
diff --git a/examples/ex5_schedule_rpc/build.gradle b/examples/ex5_schedule_rpc/build.gradle
index c7426d2..372195d 100644
--- a/examples/ex5_schedule_rpc/build.gradle
+++ b/examples/ex5_schedule_rpc/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.google.android.mobly.snippet.example5"
minSdkVersion 15
- targetSdkVersion 22
+ targetSdkVersion 26
versionCode 1
versionName "0.0.1"
}
diff --git a/third_party/sl4a/build.gradle b/third_party/sl4a/build.gradle
index ce65002..be3672f 100644
--- a/third_party/sl4a/build.gradle
+++ b/third_party/sl4a/build.gradle
@@ -24,7 +24,7 @@ android {
defaultConfig {
minSdkVersion 15
- targetSdkVersion 22
+ targetSdkVersion 26
versionCode VERSION_CODE.toInteger()
versionName VERSION_NAME