Skip to content

Commit 10acf5c

Browse files
authored
fix(android): missing AndroidX changes (#2454)
1 parent 8b606e9 commit 10acf5c

File tree

13 files changed

+43
-34
lines changed

13 files changed

+43
-34
lines changed

android-template/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ repositories {
2929

3030
dependencies {
3131
implementation fileTree(include: ['*.jar'], dir: 'libs')
32-
implementation 'androidx.appcompat:appcompat:1.0.0'
32+
implementation 'androidx.appcompat:appcompat:1.1.0'
3333
implementation project(':capacitor-android')
3434
testImplementation 'junit:junit:4.12'
3535
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
36-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
36+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3737
implementation project(':capacitor-cordova-android-plugins')
3838
}
3939

android-template/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.getcapacitor.myapp;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
67

78
import org.junit.Test;
89
import org.junit.runner.RunWith;
@@ -19,7 +20,7 @@ public class ExampleInstrumentedTest {
1920
@Test
2021
public void useAppContext() throws Exception {
2122
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2324

2425
assertEquals("com.getcapacitor.app", appContext.getPackageName());
2526
}

android/capacitor/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ android {
3232
lintOptions {
3333
abortOnError false
3434
}
35+
compileOptions {
36+
sourceCompatibility JavaVersion.VERSION_1_8
37+
targetCompatibility JavaVersion.VERSION_1_8
38+
}
3539
}
3640

3741
repositories {
@@ -42,15 +46,16 @@ repositories {
4246

4347
dependencies {
4448
implementation fileTree(dir: 'libs', include: ['*.jar'])
45-
implementation 'androidx.appcompat:appcompat:1.0.0'
49+
implementation 'androidx.appcompat:appcompat:1.1.0'
4650
implementation 'androidx.core:core:1.2.0'
4751
implementation 'com.google.android.material:material:1.1.0-rc02'
4852
implementation 'androidx.browser:browser:1.2.0'
53+
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
4954
implementation 'com.google.firebase:firebase-messaging:18.0.0'
50-
implementation 'com.google.android.gms:play-services-location:16.0.0'
55+
implementation 'com.google.android.gms:play-services-location:17.0.0'
5156
testImplementation 'junit:junit:4.12'
5257
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
53-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
58+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
5459
implementation 'org.apache.cordova:framework:7.0.0'
5560
}
5661

android/capacitor/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.getcapacitor.android;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
67

78
import org.junit.Test;
89
import org.junit.runner.RunWith;
@@ -19,8 +20,8 @@ public class ExampleInstrumentedTest {
1920
@Test
2021
public void useAppContext() throws Exception {
2122
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2324

24-
assertEquals("com.getcapacitor.android", appContext.getPackageName());
25+
assertEquals("com.getcapacitor.android.test", appContext.getPackageName());
2526
}
2627
}

android/capacitor/src/main/java/com/getcapacitor/plugin/notification/LocalNotificationManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.Date;
3030
import java.util.List;
3131

32-
import static androidx.core.app.NotificationCompat.VISIBILITY_PRIVATE;
3332

3433
/**
3534
* Contains implementations for all notification actions

example/android/app/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@ android {
88
targetSdkVersion 29
99
versionCode 1
1010
versionName "1.0"
11-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
1414
release {
1515
minifyEnabled false
1616
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1717
}
1818
}
19+
compileOptions {
20+
sourceCompatibility JavaVersion.VERSION_1_8
21+
targetCompatibility JavaVersion.VERSION_1_8
22+
}
1923
}
2024

2125
dependencies {
2226
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:28.0.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25-
implementation 'com.android.support:design:28.0.0'
26-
implementation 'com.android.support:customtabs:28.0.0'
27+
implementation 'androidx.appcompat:appcompat:1.1.0'
2728
testImplementation 'junit:junit:4.12'
28-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
29-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
30+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3031
implementation project(':android-capacitor')
3132
// Uncomment to develop the plugin template
3233
// implementation project(':plugin')

example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.getcapacitor.myapp;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
67

78
import org.junit.Test;
89
import org.junit.runner.RunWith;
@@ -19,8 +20,8 @@ public class ExampleInstrumentedTest {
1920
@Test
2021
public void useAppContext() throws Exception {
2122
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2324

24-
assertEquals("com.avocadojs.myapp", appContext.getPackageName());
25+
assertEquals("com.getcapacitor.app", appContext.getPackageName());
2526
}
2627
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ package="com.getcapacitor.myapp">
3131
</activity>
3232

3333
<provider
34-
android:name="android.support.v4.content.FileProvider"
34+
android:name="androidx.core.content.FileProvider"
3535
android:authorities="${applicationId}.fileprovider"
3636
android:exported="false"
3737
android:grantUriPermissions="true">

example/android/app/src/main/assets/capacitor.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"launchShowDuration": 12345
99
}
1010
}
11-
}
11+
}

example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ':app', ':android-capacitor', ':plugin'
1+
include ':app', ':android-capacitor'//, ':plugin'
22
project(':android-capacitor').projectDir=new File('../../android/capacitor/')
33
// Uncomment to test/dev the plugin (make sure to change its dependency on capacitor-android to a local reference)
44
// project(':plugin').projectDir=new File('../../plugin-template/android/plugin/')

0 commit comments

Comments
 (0)