From 10acf5c1fcb56cac54a512619dfb2c6f433d6adb Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 19 Feb 2020 17:43:31 +0100 Subject: [PATCH] fix(android): missing AndroidX changes (#2454) --- android-template/app/build.gradle | 4 ++-- .../myapp/ExampleInstrumentedTest.java | 7 ++++--- android/capacitor/build.gradle | 11 ++++++++--- .../android/ExampleInstrumentedTest.java | 9 +++++---- .../notification/LocalNotificationManager.java | 1 - example/android/app/build.gradle | 15 ++++++++------- .../myapp/ExampleInstrumentedTest.java | 9 +++++---- example/android/app/src/main/AndroidManifest.xml | 2 +- .../app/src/main/assets/capacitor.config.json | 2 +- example/android/settings.gradle | 2 +- .../IonicRunner/IonicRunner/capacitor.config.json | 2 +- plugin-template/android/build.gradle | 6 +++--- .../android/ExampleInstrumentedTest.java | 7 ++++--- 13 files changed, 43 insertions(+), 34 deletions(-) diff --git a/android-template/app/build.gradle b/android-template/app/build.gradle index 3d25b4adc3..ccee48b82b 100644 --- a/android-template/app/build.gradle +++ b/android-template/app/build.gradle @@ -29,11 +29,11 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation project(':capacitor-android') testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation project(':capacitor-cordova-android-plugins') } diff --git a/android-template/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java b/android-template/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java index 14273cf932..8834b0a514 100644 --- a/android-template/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +++ b/android-template/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java @@ -1,8 +1,9 @@ package com.getcapacitor.myapp; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,7 +20,7 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.getcapacitor.app", appContext.getPackageName()); } diff --git a/android/capacitor/build.gradle b/android/capacitor/build.gradle index 3710c0c0a9..f49c66596c 100644 --- a/android/capacitor/build.gradle +++ b/android/capacitor/build.gradle @@ -32,6 +32,10 @@ android { lintOptions { abortOnError false } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } repositories { @@ -42,15 +46,16 @@ repositories { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core:1.2.0' implementation 'com.google.android.material:material:1.1.0-rc02' implementation 'androidx.browser:browser:1.2.0' + implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'com.google.firebase:firebase-messaging:18.0.0' - implementation 'com.google.android.gms:play-services-location:16.0.0' + implementation 'com.google.android.gms:play-services-location:17.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'org.apache.cordova:framework:7.0.0' } diff --git a/android/capacitor/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java b/android/capacitor/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java index 1d58c77890..44d94bf2d8 100644 --- a/android/capacitor/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +++ b/android/capacitor/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java @@ -1,8 +1,9 @@ package com.getcapacitor.android; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,8 +20,8 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.getcapacitor.android", appContext.getPackageName()); + assertEquals("com.getcapacitor.android.test", appContext.getPackageName()); } } diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java index e128c69f72..2e095269f9 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java @@ -29,7 +29,6 @@ import java.util.Date; import java.util.List; -import static androidx.core.app.NotificationCompat.VISIBILITY_PRIVATE; /** * Contains implementations for all notification actions diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 693daa0488..20d06704fc 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -8,7 +8,7 @@ android { targetSdkVersion 29 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -16,17 +16,18 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support:customtabs:28.0.0' + implementation 'androidx.appcompat:appcompat:1.1.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation project(':android-capacitor') // Uncomment to develop the plugin template // implementation project(':plugin') diff --git a/example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java b/example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java index 074b3b83f2..3b228b21f5 100644 --- a/example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +++ b/example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java @@ -1,8 +1,9 @@ package com.getcapacitor.myapp; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,8 +20,8 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.avocadojs.myapp", appContext.getPackageName()); + assertEquals("com.getcapacitor.app", appContext.getPackageName()); } } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 768bb43d4c..75c05281f7 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -31,7 +31,7 @@ package="com.getcapacitor.myapp"> diff --git a/example/android/app/src/main/assets/capacitor.config.json b/example/android/app/src/main/assets/capacitor.config.json index c46c43283e..5bd0006f90 100644 --- a/example/android/app/src/main/assets/capacitor.config.json +++ b/example/android/app/src/main/assets/capacitor.config.json @@ -8,4 +8,4 @@ "launchShowDuration": 12345 } } -} +} \ No newline at end of file diff --git a/example/android/settings.gradle b/example/android/settings.gradle index c19086b080..342ec84b45 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,4 +1,4 @@ -include ':app', ':android-capacitor', ':plugin' +include ':app', ':android-capacitor'//, ':plugin' project(':android-capacitor').projectDir=new File('../../android/capacitor/') // Uncomment to test/dev the plugin (make sure to change its dependency on capacitor-android to a local reference) // project(':plugin').projectDir=new File('../../plugin-template/android/plugin/') diff --git a/example/ios/IonicRunner/IonicRunner/capacitor.config.json b/example/ios/IonicRunner/IonicRunner/capacitor.config.json index c46c43283e..5bd0006f90 100644 --- a/example/ios/IonicRunner/IonicRunner/capacitor.config.json +++ b/example/ios/IonicRunner/IonicRunner/capacitor.config.json @@ -8,4 +8,4 @@ "launchShowDuration": 12345 } } -} +} \ No newline at end of file diff --git a/plugin-template/android/build.gradle b/plugin-template/android/build.gradle index f142bee003..b7218f9054 100644 --- a/plugin-template/android/build.gradle +++ b/plugin-template/android/build.gradle @@ -17,7 +17,7 @@ android { targetSdkVersion 29 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -41,6 +41,6 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(':capacitor-android') testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } diff --git a/plugin-template/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java b/plugin-template/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java index 1d58c77890..64f83739d7 100644 --- a/plugin-template/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +++ b/plugin-template/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java @@ -1,8 +1,9 @@ package com.getcapacitor.android; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,7 +20,7 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.getcapacitor.android", appContext.getPackageName()); }