Skip to content

Commit c713881

Browse files
committed
fix: disable desugaring for example app to fix issues with detox testing
1 parent 808ae02 commit c713881

File tree

8 files changed

+68
-51
lines changed

8 files changed

+68
-51
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,28 @@ Integration tests are responsible for ensuring that the plugin works against the
120120
To run the test you must first install and setup detox. Please follow the guide here:
121121
https://wix.github.io/Detox/docs/introduction/environment-setup
122122

123-
Build the tests using detox-cli:
123+
Build the tests using detox-cli in the example folder:
124124

125125
iOS:
126126
```bash
127-
detox build --configuration ios.sim.debug
127+
detox build --configuration ios.sim.release
128128
```
129129

130130
Android:
131131
```bash
132-
detox build --configuration android.emu.debug
132+
detox build --configuration android.emu.release
133133
```
134134

135135
Google Maps React Native Navigation SDK integration tests can be run with the following command:
136136

137137
iOS
138138
```bash
139-
yarn run example test:ios
139+
yarn run example test:ios-release
140140
```
141141

142142
Android:
143143
```bash
144-
yarn run example test:android
144+
yarn run example detox:test:android-release
145145
```
146146

147147
When adding new tests, you need to first add the detox part in the [e2e folder](./example/e2e) and then the actual logical part of the test in the [integration tests page](./example/src/screens/IntegrationTestsScreen.tsx) of the example app.

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ android {
5656

5757
buildTypes {
5858
release {
59-
minifyEnabled false
59+
minifyEnabled true
6060
}
6161
}
6262

android/src/main/java/com/google/android/react/navsdk/AndroidAutoBaseScreen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import androidx.lifecycle.Lifecycle;
3535
import androidx.lifecycle.LifecycleObserver;
3636
import androidx.lifecycle.LifecycleOwner;
37+
import com.facebook.proguard.annotations.DoNotStrip;
3738
import com.facebook.react.bridge.ReadableMap;
3839
import com.google.android.gms.maps.CameraUpdate;
3940
import com.google.android.gms.maps.CameraUpdateFactory;
@@ -48,6 +49,7 @@
4849
// For more information on using Android Auto with the Google Navigation SDK, refer to the official
4950
// documentation:
5051
// https://developers.google.com/maps/documentation/navigation/android-sdk/android-auto
52+
@DoNotStrip
5153
public abstract class AndroidAutoBaseScreen extends Screen
5254
implements SurfaceCallback, INavigationViewController {
5355
private static final String VIRTUAL_DISPLAY_NAME = "AndroidAutoNavScreen";

android/src/main/java/com/google/android/react/navsdk/Package.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package com.google.android.react.navsdk;
1515

16+
import com.facebook.proguard.annotations.DoNotStrip;
1617
import com.facebook.react.ReactPackage;
1718
import com.facebook.react.bridge.NativeModule;
1819
import com.facebook.react.bridge.ReactApplicationContext;
@@ -21,6 +22,7 @@
2122
import java.util.Arrays;
2223
import java.util.List;
2324

25+
@DoNotStrip
2426
public class Package implements ReactPackage {
2527

2628
private NavViewManager mNavViewManager;

example/.detoxrc.js

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,82 +18,86 @@
1818
module.exports = {
1919
testRunner: {
2020
args: {
21-
'$0': 'jest',
22-
config: 'e2e/jest.config.js'
21+
$0: 'jest',
22+
config: 'e2e/jest.config.js',
2323
},
2424
jest: {
25-
setupTimeout: 120000
26-
}
25+
setupTimeout: 120000,
26+
},
2727
},
2828
apps: {
2929
'ios.debug': {
3030
type: 'ios.app',
31-
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/SampleApp.app',
32-
build: 'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
31+
binaryPath:
32+
'ios/build/Build/Products/Debug-iphonesimulator/SampleApp.app',
33+
build:
34+
'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
3335
},
3436
'ios.release': {
3537
type: 'ios.app',
36-
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/SampleApp.app',
37-
build: 'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
38+
binaryPath:
39+
'ios/build/Build/Products/Release-iphonesimulator/SampleApp.app',
40+
build:
41+
'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
3842
},
3943
'android.debug': {
4044
type: 'android.apk',
4145
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
42-
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
43-
reversePorts: [
44-
8081
45-
]
46+
build:
47+
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
48+
reversePorts: [8081],
4649
},
4750
'android.release': {
4851
type: 'android.apk',
4952
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
50-
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
51-
}
53+
build:
54+
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
55+
},
5256
},
5357
devices: {
5458
simulator: {
5559
type: 'ios.simulator',
5660
device: {
57-
type: 'iPhone 15 Pro'
58-
}
61+
type: 'iPhone 16 Pro',
62+
},
5963
},
6064
attached: {
6165
type: 'android.attached',
6266
device: {
63-
adbName: '.*'
64-
}
67+
adbName: '.*',
68+
},
6569
},
6670
emulator: {
6771
type: 'android.emulator',
6872
device: {
69-
avdName: 'Pixel_7_Pro_API_33'
70-
}
71-
}
73+
avdName: 'Pixel_8_API_35',
74+
},
75+
},
7276
},
7377
configurations: {
7478
'ios.sim.debug': {
7579
device: 'simulator',
76-
app: 'ios.debug'
80+
app: 'ios.debug',
7781
},
7882
'ios.sim.release': {
7983
device: 'simulator',
80-
app: 'ios.release'
84+
app: 'ios.release',
8185
},
8286
'android.att.debug': {
8387
device: 'attached',
84-
app: 'android.debug'
88+
app: 'android.debug',
8589
},
8690
'android.att.release': {
8791
device: 'attached',
88-
app: 'android.release'
92+
app: 'android.release',
8993
},
9094
'android.emu.debug': {
9195
device: 'emulator',
92-
app: 'android.debug'
96+
app: 'android.debug',
9397
},
9498
'android.emu.release': {
9599
device: 'emulator',
96-
app: 'android.release'
97-
}
98-
}
100+
app: 'android.release',
101+
},
102+
},
99103
};

example/android/app/build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ react {
7474
/**
7575
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
7676
*/
77-
def enableProguardInReleaseBuilds = false
77+
def enableProguardInReleaseBuilds = true
78+
79+
80+
/**
81+
* Set this to true to enable desugaring if minSdkVersion is set to 34 or below.
82+
* Note that this currently affects Detox testing with release builds and therefore is not enabled by default.
83+
*/
84+
def enableDesugaring = false
7885

7986
/**
8087
* The preferred build flavor of JavaScriptCore (JSC)
@@ -121,12 +128,11 @@ android {
121128
// see https://reactnative.dev/docs/signed-apk-android.
122129
signingConfig signingConfigs.debug
123130
minifyEnabled enableProguardInReleaseBuilds
124-
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
125-
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
131+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
126132
}
127133
}
128134
compileOptions {
129-
coreLibraryDesugaringEnabled true
135+
coreLibraryDesugaringEnabled enableDesugaring
130136
sourceCompatibility JavaVersion.VERSION_17
131137
targetCompatibility JavaVersion.VERSION_17
132138
}
@@ -152,7 +158,7 @@ dependencies {
152158
implementation 'com.google.android.libraries.navigation:navigation:6.0.0'
153159

154160
// Desugar Java 8+ APIs
155-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
161+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
156162
}
157163

158164
secrets {

example/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
buildscript {
1616
ext {
1717
buildToolsVersion = "35.0.0"
18-
minSdkVersion = 24
18+
// If minSDKVersion is set below 34, make sure to enable desugaring
19+
// to use certain Java 8+ APIs on lower API levels
20+
// by setting enableDesugaring true in app/build.gradle file.
21+
minSdkVersion = 34
1922
compileSdkVersion = 35
2023
targetSdkVersion = 34
2124
ndkVersion = "26.1.10909125"

example/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
"scripts": {
66
"start": "react-native start",
77
"android": "react-native run-android",
8+
"android-release": "react-native run-android --mode release",
89
"ios": "react-native run-ios",
10+
"ios-release": "react-native run-ios --mode release",
911
"lint": "eslint .",
1012
"test": "jest",
1113
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
1214
"build:ios": "cd ios && xcodebuild -workspace SampleApp.xcworkspace -scheme SampleApp -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
13-
"build:ios-debug": "detox build --configuration ios.sim.debug",
14-
"build:ios-release": "detox build --configuration ios.sim.release",
15-
"build:android-debug": "detox build --configuration android.emu.debug",
16-
"build:android-release": "detox build --configuration android.emu.release",
17-
"test:ios": "detox test --configuration ios.sim.release",
18-
"test:ios-debug": "detox test --configuration ios.sim.debug",
19-
"test:ios-release": "detox test --configuration ios.sim.release",
20-
"test:android": "detox test --configuration android.emu.release",
21-
"test:android-debug": "detox test --configuration android.emu.debug",
22-
"test:android-release": "detox test --configuration android.emu.release"
15+
"detox:build:ios-debug": "detox build --configuration ios.sim.debug",
16+
"detox:build:ios-release": "detox build --configuration ios.sim.release",
17+
"detox:build:android-debug": "detox build --configuration android.emu.debug",
18+
"detox:build:android-release": "detox build --configuration android.emu.release",
19+
"detox:test:ios-debug": "detox test --configuration ios.sim.debug",
20+
"detox:test:ios-release": "detox test --configuration ios.sim.release",
21+
"detox:test:android-debug": "detox test --configuration android.emu.debug",
22+
"detox:test:android-release": "detox test --configuration android.emu.release"
2323
},
2424
"dependencies": {
2525
"@react-navigation/native": "^6.1.18",

0 commit comments

Comments
 (0)