Skip to content

Commit

Permalink
fix: disable desugaring for example app to fix issues with detox testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerttu committed Dec 5, 2024
1 parent 808ae02 commit c713881
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 51 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,28 @@ Integration tests are responsible for ensuring that the plugin works against the
To run the test you must first install and setup detox. Please follow the guide here:
https://wix.github.io/Detox/docs/introduction/environment-setup

Build the tests using detox-cli:
Build the tests using detox-cli in the example folder:

iOS:
```bash
detox build --configuration ios.sim.debug
detox build --configuration ios.sim.release
```

Android:
```bash
detox build --configuration android.emu.debug
detox build --configuration android.emu.release
```

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

iOS
```bash
yarn run example test:ios
yarn run example test:ios-release
```

Android:
```bash
yarn run example test:android
yarn run example detox:test:android-release
```

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.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReadableMap;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
Expand All @@ -48,6 +49,7 @@
// For more information on using Android Auto with the Google Navigation SDK, refer to the official
// documentation:
// https://developers.google.com/maps/documentation/navigation/android-sdk/android-auto
@DoNotStrip
public abstract class AndroidAutoBaseScreen extends Screen
implements SurfaceCallback, INavigationViewController {
private static final String VIRTUAL_DISPLAY_NAME = "AndroidAutoNavScreen";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.google.android.react.navsdk;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -21,6 +22,7 @@
import java.util.Arrays;
import java.util.List;

@DoNotStrip
public class Package implements ReactPackage {

private NavViewManager mNavViewManager;
Expand Down
62 changes: 33 additions & 29 deletions example/.detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,82 +18,86 @@
module.exports = {
testRunner: {
args: {
'$0': 'jest',
config: 'e2e/jest.config.js'
$0: 'jest',
config: 'e2e/jest.config.js',
},
jest: {
setupTimeout: 120000
}
setupTimeout: 120000,
},
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/SampleApp.app',
build: 'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
binaryPath:
'ios/build/Build/Products/Debug-iphonesimulator/SampleApp.app',
build:
'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
},
'ios.release': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/SampleApp.app',
build: 'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
binaryPath:
'ios/build/Build/Products/Release-iphonesimulator/SampleApp.app',
build:
'xcodebuild -workspace ios/SampleApp.xcworkspace -scheme SampleApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [
8081
]
build:
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [8081],
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
}
build:
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
},
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 15 Pro'
}
type: 'iPhone 16 Pro',
},
},
attached: {
type: 'android.attached',
device: {
adbName: '.*'
}
adbName: '.*',
},
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_7_Pro_API_33'
}
}
avdName: 'Pixel_8_API_35',
},
},
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug'
app: 'ios.debug',
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release'
app: 'ios.release',
},
'android.att.debug': {
device: 'attached',
app: 'android.debug'
app: 'android.debug',
},
'android.att.release': {
device: 'attached',
app: 'android.release'
app: 'android.release',
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug'
app: 'android.debug',
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
}
app: 'android.release',
},
},
};
16 changes: 11 additions & 5 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ react {
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
def enableProguardInReleaseBuilds = true


/**
* Set this to true to enable desugaring if minSdkVersion is set to 34 or below.
* Note that this currently affects Detox testing with release builds and therefore is not enabled by default.
*/
def enableDesugaring = false

/**
* The preferred build flavor of JavaScriptCore (JSC)
Expand Down Expand Up @@ -121,12 +128,11 @@ android {
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
compileOptions {
coreLibraryDesugaringEnabled true
coreLibraryDesugaringEnabled enableDesugaring
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
Expand All @@ -152,7 +158,7 @@ dependencies {
implementation 'com.google.android.libraries.navigation:navigation:6.0.0'

// Desugar Java 8+ APIs
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
}

secrets {
Expand Down
5 changes: 4 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
buildscript {
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 24
// If minSDKVersion is set below 34, make sure to enable desugaring
// to use certain Java 8+ APIs on lower API levels
// by setting enableDesugaring true in app/build.gradle file.
minSdkVersion = 34
compileSdkVersion = 35
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
Expand Down
20 changes: 10 additions & 10 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"android-release": "react-native run-android --mode release",
"ios": "react-native run-ios",
"ios-release": "react-native run-ios --mode release",
"lint": "eslint .",
"test": "jest",
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
"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",
"build:ios-debug": "detox build --configuration ios.sim.debug",
"build:ios-release": "detox build --configuration ios.sim.release",
"build:android-debug": "detox build --configuration android.emu.debug",
"build:android-release": "detox build --configuration android.emu.release",
"test:ios": "detox test --configuration ios.sim.release",
"test:ios-debug": "detox test --configuration ios.sim.debug",
"test:ios-release": "detox test --configuration ios.sim.release",
"test:android": "detox test --configuration android.emu.release",
"test:android-debug": "detox test --configuration android.emu.debug",
"test:android-release": "detox test --configuration android.emu.release"
"detox:build:ios-debug": "detox build --configuration ios.sim.debug",
"detox:build:ios-release": "detox build --configuration ios.sim.release",
"detox:build:android-debug": "detox build --configuration android.emu.debug",
"detox:build:android-release": "detox build --configuration android.emu.release",
"detox:test:ios-debug": "detox test --configuration ios.sim.debug",
"detox:test:ios-release": "detox test --configuration ios.sim.release",
"detox:test:android-debug": "detox test --configuration android.emu.debug",
"detox:test:android-release": "detox test --configuration android.emu.release"
},
"dependencies": {
"@react-navigation/native": "^6.1.18",
Expand Down

0 comments on commit c713881

Please sign in to comment.