diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index e89978c..093a210 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -5,15 +5,17 @@ on: push: branches: [ main ] paths: - - '.github/workflows/example.yml' - - 'example/**' + - '**' - '!example/README.md' + - '!README.md' + - '!test/**' pull_request: branches: [ main, 'v[0-9]+.[0-9]+' ] paths: - - '.github/workflows/example.yml' - - 'example/**' + - '**' - '!example/README.md' + - '!README.md' + - '!test/**' jobs: build-android: @@ -22,6 +24,22 @@ jobs: strategy: matrix: node-version: [16.x, 18.x, 20.x] + include: + - node-version: 16.x + gradle-version: 6.5 + agp-version: 4.1.3 + java-version: 11 + rn-version: 0.65.3 + - node-version: 18.x + gradle-version: 7.5 + agp-version: 7.4.2 + java-version: 11 + rn-version: 0.71.12 + - node-version: 20.x + gradle-version: 8.2 + agp-version: 8.2.2 + java-version: 17 + rn-version: 0.72.10 steps: - uses: actions/checkout@v3 @@ -31,12 +49,37 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Pre-build dependencies - run: npm install yarn + - name: Use JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + + - name: Use Gradle ${{ matrix.gradle-version }} + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: ${{ matrix.gradle-version }} + + - name: Inject AGP version + run: echo agpVersion="${{ matrix.agp-version }}" >> local.properties + working-directory: example/android - name: Install dependencies run: yarn bootstrap + - name: Change React Native versions + run: yarn upgrade react-native@${{ matrix.rn-version }} + working-directory: example + + - name: Copy project files + if: ${{ (matrix.gradle-version == '8.2') || (matrix.gradle-version == '6.5')}} + run: sh copy.sh + working-directory: resources/.test/gradle_${{ matrix.gradle-version }} + + - name: Generate gradle wrapper + run: gradle wrapper --gradle-version ${{ matrix.gradle-version }} --distribution-type all + working-directory: example/android + - name: Build bundle run: yarn example android-bundle @@ -45,7 +88,7 @@ jobs: working-directory: example/android build-ios: - runs-on: macos-latest + runs-on: macos-12 strategy: matrix: @@ -59,8 +102,10 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Pre-build dependencies - run: npm install yarn + - name: Setup Cocoapods 1.14.3 + uses: maxim-lobanov/setup-cocoapods@v1 + with: + version: 1.14.3 - name: Install dependencies run: yarn bootstrap @@ -76,4 +121,4 @@ jobs: -scheme VoiceProcessorExample -derivedDataPath ddp CODE_SIGNING_ALLOWED=NO - working-directory: example/ios \ No newline at end of file + working-directory: example/ios diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 10c4c62..49e5f33 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,13 +7,13 @@ on: paths: - '**' - '!README.md' - - '!example/README.md' + - '!example/**' pull_request: branches: [ main, 'v[0-9]+.[0-9]+' ] paths: - '**' - '!README.md' - - '!example/README.md' + - '!example/**' defaults: run: diff --git a/android/build.gradle b/android/build.gradle index 5f6a48f..946a792 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:7.2.1" + classpath "com.android.tools.build:gradle:7.4.2" } } @@ -28,6 +28,17 @@ def getExtOrIntegerDefault(name) { } android { + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() >= 7) { + namespace "ai.picovoice.reactnative.voiceprocessor" + } + + if (agpVersion.tokenize('.')[0].toInteger() >= 8) { + buildFeatures { + buildConfig = true + } + } + compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") defaultConfig { diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index d570ae9..c1b3a11 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -89,9 +89,18 @@ def reactNativeArchitectures() { } android { + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() >= 7) { + namespace "ai.picovoice.reactnative.voiceprocessorexample" + } + + if (agpVersion.tokenize('.')[0].toInteger() >= 8) { + buildFeatures { + buildConfig = true + } + } compileSdk rootProject.ext.compileSdkVersion - namespace "ai.picovoice.reactnative.voiceprocessorexample" defaultConfig { applicationId "ai.picovoice.reactnative.voiceprocessorexample" minSdkVersion rootProject.ext.minSdkVersion diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 4b185bc..0000000 --- a/example/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/example/android/app/src/debug/java/ai/picovoice/reactnative/voiceprocessorexample/ReactNativeFlipper.java b/example/android/app/src/debug/java/ai/picovoice/reactnative/voiceprocessorexample/ReactNativeFlipper.java deleted file mode 100644 index d1c6ab6..0000000 --- a/example/android/app/src/debug/java/ai/picovoice/reactnative/voiceprocessorexample/ReactNativeFlipper.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ - -package ai.picovoice.reactnative.voiceprocessorexample; - -import android.content.Context; - -import com.facebook.flipper.android.AndroidFlipperClient; -import com.facebook.flipper.android.utils.FlipperUtils; -import com.facebook.flipper.core.FlipperClient; -import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; -import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; -import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; -import com.facebook.flipper.plugins.inspector.DescriptorMapping; -import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; -import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; -import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; -import com.facebook.react.ReactInstanceEventListener; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.modules.network.NetworkingModule; - -import okhttp3.OkHttpClient; - -/** - * Class responsible of loading Flipper inside your React Native application. This is the debug - * flavor of it. Here you can add your own plugins and customize the Flipper setup. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - if (FlipperUtils.shouldEnableFlipper(context)) { - final FlipperClient client = AndroidFlipperClient.getInstance(context); - - client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new DatabasesFlipperPlugin(context)); - client.addPlugin(new SharedPreferencesFlipperPlugin(context)); - client.addPlugin(CrashReporterPlugin.getInstance()); - - NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); - NetworkingModule.setCustomClientBuilder( - new NetworkingModule.CustomClientBuilder() { - @Override - public void apply(OkHttpClient.Builder builder) { - builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); - } - }); - client.addPlugin(networkFlipperPlugin); - client.start(); - - // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized - // Hence we run if after all native modules have been initialized - ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - if (reactContext == null) { - reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceEventListener() { - @Override - public void onReactContextInitialized(ReactContext reactContext) { - reactInstanceManager.removeReactInstanceEventListener(this); - reactContext.runOnNativeModulesQueueThread( - new Runnable() { - @Override - public void run() { - client.addPlugin(new FrescoFlipperPlugin()); - } - }); - } - }); - } else { - client.addPlugin(new FrescoFlipperPlugin()); - } - } - } -} diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index bdbed10..448d842 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ - + diff --git a/example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainApplication.java b/example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainApplication.java index 3133e28..2f00c37 100644 --- a/example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainApplication.java +++ b/example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainApplication.java @@ -58,6 +58,5 @@ public void onCreate() { // If you opted-in for the New Architecture, we load the native entry point for this app. DefaultNewArchitectureEntryPoint.load(); } - ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } diff --git a/example/android/app/src/release/java/ai/picovoice/reactnative/ReactNativeFlipper.java b/example/android/app/src/release/java/ai/picovoice/reactnative/ReactNativeFlipper.java deleted file mode 100644 index b3eba1b..0000000 --- a/example/android/app/src/release/java/ai/picovoice/reactnative/ReactNativeFlipper.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ - -package ai.picovoice.reactnative.voiceprocessorexample; - -import android.content.Context; - -import com.facebook.react.ReactInstanceManager; - -/** - * Class responsible of loading Flipper inside your React Native application. This is the release - * flavor of it so it's empty as we don't want to load Flipper. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - // Do nothing as we don't want to initialize Flipper on Release. - } -} diff --git a/example/android/build.gradle b/example/android/build.gradle index 148d08f..adf1606 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -11,8 +11,22 @@ buildscript { google() mavenCentral() } + + def localProperties = new Properties() + def localPropertiesFile = rootProject.file('local.properties') + if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } + } + + def agpVersion = localProperties.getProperty('agpVersion') + if (agpVersion == null) { + agpVersion = '7.4.2' + } + dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath "com.android.tools.build:gradle:$agpVersion" classpath 'com.facebook.react:react-native-gradle-plugin' } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index d5005ec..66f3d02 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,14 +2,14 @@ PODS: - boost (1.76.0) - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - - FBLazyVector (0.71.3) - - FBReactNativeSpec (0.71.3): + - FBLazyVector (0.71.12) + - FBReactNativeSpec (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTRequired (= 0.71.3) - - RCTTypeSafety (= 0.71.3) - - React-Core (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) + - RCTRequired (= 0.71.12) + - RCTTypeSafety (= 0.71.12) + - React-Core (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) - Flipper (0.125.0): - Flipper-Folly (~> 2.6) - Flipper-RSocket (~> 1.4) @@ -73,9 +73,9 @@ PODS: - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - - hermes-engine (0.71.3): - - hermes-engine/Pre-built (= 0.71.3) - - hermes-engine/Pre-built (0.71.3) + - hermes-engine (0.71.12): + - hermes-engine/Pre-built (= 0.71.12) + - hermes-engine/Pre-built (0.71.12) - ios-voice-processor (1.1.0) - libevent (2.1.12) - OpenSSL-Universal (1.1.1100) @@ -96,26 +96,26 @@ PODS: - fmt (~> 6.2.1) - glog - libevent - - RCTRequired (0.71.3) - - RCTTypeSafety (0.71.3): - - FBLazyVector (= 0.71.3) - - RCTRequired (= 0.71.3) - - React-Core (= 0.71.3) - - React (0.71.3): - - React-Core (= 0.71.3) - - React-Core/DevSupport (= 0.71.3) - - React-Core/RCTWebSocket (= 0.71.3) - - React-RCTActionSheet (= 0.71.3) - - React-RCTAnimation (= 0.71.3) - - React-RCTBlob (= 0.71.3) - - React-RCTImage (= 0.71.3) - - React-RCTLinking (= 0.71.3) - - React-RCTNetwork (= 0.71.3) - - React-RCTSettings (= 0.71.3) - - React-RCTText (= 0.71.3) - - React-RCTVibration (= 0.71.3) - - React-callinvoker (0.71.3) - - React-Codegen (0.71.3): + - RCTRequired (0.71.12) + - RCTTypeSafety (0.71.12): + - FBLazyVector (= 0.71.12) + - RCTRequired (= 0.71.12) + - React-Core (= 0.71.12) + - React (0.71.12): + - React-Core (= 0.71.12) + - React-Core/DevSupport (= 0.71.12) + - React-Core/RCTWebSocket (= 0.71.12) + - React-RCTActionSheet (= 0.71.12) + - React-RCTAnimation (= 0.71.12) + - React-RCTBlob (= 0.71.12) + - React-RCTImage (= 0.71.12) + - React-RCTLinking (= 0.71.12) + - React-RCTNetwork (= 0.71.12) + - React-RCTSettings (= 0.71.12) + - React-RCTText (= 0.71.12) + - React-RCTVibration (= 0.71.12) + - React-callinvoker (0.71.12) + - React-Codegen (0.71.12): - FBReactNativeSpec - hermes-engine - RCT-Folly @@ -126,297 +126,299 @@ PODS: - React-jsiexecutor - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - React-Core (0.71.3): + - React-Core (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.3) - - React-cxxreact (= 0.71.3) + - React-Core/Default (= 0.71.12) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/CoreModulesHeaders (0.71.3): + - React-Core/CoreModulesHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/Default (0.71.3): + - React-Core/Default (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/DevSupport (0.71.3): + - React-Core/DevSupport (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.3) - - React-Core/RCTWebSocket (= 0.71.3) - - React-cxxreact (= 0.71.3) + - React-Core/Default (= 0.71.12) + - React-Core/RCTWebSocket (= 0.71.12) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-jsinspector (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-jsinspector (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTActionSheetHeaders (0.71.3): + - React-Core/RCTActionSheetHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTAnimationHeaders (0.71.3): + - React-Core/RCTAnimationHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTBlobHeaders (0.71.3): + - React-Core/RCTBlobHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTImageHeaders (0.71.3): + - React-Core/RCTImageHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTLinkingHeaders (0.71.3): + - React-Core/RCTLinkingHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTNetworkHeaders (0.71.3): + - React-Core/RCTNetworkHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTSettingsHeaders (0.71.3): + - React-Core/RCTSettingsHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTTextHeaders (0.71.3): + - React-Core/RCTTextHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTVibrationHeaders (0.71.3): + - React-Core/RCTVibrationHeaders (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - React-Core/Default - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-Core/RCTWebSocket (0.71.3): + - React-Core/RCTWebSocket (0.71.12): - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.3) - - React-cxxreact (= 0.71.3) + - React-Core/Default (= 0.71.12) + - React-cxxreact (= 0.71.12) - React-hermes - - React-jsi (= 0.71.3) - - React-jsiexecutor (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-jsi (= 0.71.12) + - React-jsiexecutor (= 0.71.12) + - React-perflogger (= 0.71.12) - Yoga - - React-CoreModules (0.71.3): + - React-CoreModules (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.3) - - React-Codegen (= 0.71.3) - - React-Core/CoreModulesHeaders (= 0.71.3) - - React-jsi (= 0.71.3) + - RCTTypeSafety (= 0.71.12) + - React-Codegen (= 0.71.12) + - React-Core/CoreModulesHeaders (= 0.71.12) + - React-jsi (= 0.71.12) - React-RCTBlob - - React-RCTImage (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-cxxreact (0.71.3): + - React-RCTImage (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-cxxreact (0.71.12): - boost (= 1.76.0) - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.3) - - React-jsi (= 0.71.3) - - React-jsinspector (= 0.71.3) - - React-logger (= 0.71.3) - - React-perflogger (= 0.71.3) - - React-runtimeexecutor (= 0.71.3) - - React-hermes (0.71.3): + - React-callinvoker (= 0.71.12) + - React-jsi (= 0.71.12) + - React-jsinspector (= 0.71.12) + - React-logger (= 0.71.12) + - React-perflogger (= 0.71.12) + - React-runtimeexecutor (= 0.71.12) + - React-hermes (0.71.12): - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - RCT-Folly/Futures (= 2021.07.22.00) - - React-cxxreact (= 0.71.3) + - React-cxxreact (= 0.71.12) - React-jsi - - React-jsiexecutor (= 0.71.3) - - React-jsinspector (= 0.71.3) - - React-perflogger (= 0.71.3) - - React-jsi (0.71.3): + - React-jsiexecutor (= 0.71.12) + - React-jsinspector (= 0.71.12) + - React-perflogger (= 0.71.12) + - React-jsi (0.71.12): - boost (= 1.76.0) - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-jsiexecutor (0.71.3): + - React-jsiexecutor (0.71.12): - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-cxxreact (= 0.71.3) - - React-jsi (= 0.71.3) - - React-perflogger (= 0.71.3) - - React-jsinspector (0.71.3) - - React-logger (0.71.3): + - React-cxxreact (= 0.71.12) + - React-jsi (= 0.71.12) + - React-perflogger (= 0.71.12) + - React-jsinspector (0.71.12) + - React-logger (0.71.12): - glog - - react-native-voice-processor (1.2.0): + - react-native-voice-processor (1.2.1): - ios-voice-processor (~> 1.1.0) - React-Core - - React-perflogger (0.71.3) - - React-RCTActionSheet (0.71.3): - - React-Core/RCTActionSheetHeaders (= 0.71.3) - - React-RCTAnimation (0.71.3): + - React-perflogger (0.71.12) + - React-RCTActionSheet (0.71.12): + - React-Core/RCTActionSheetHeaders (= 0.71.12) + - React-RCTAnimation (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.3) - - React-Codegen (= 0.71.3) - - React-Core/RCTAnimationHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTAppDelegate (0.71.3): + - RCTTypeSafety (= 0.71.12) + - React-Codegen (= 0.71.12) + - React-Core/RCTAnimationHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTAppDelegate (0.71.12): - RCT-Folly - RCTRequired - RCTTypeSafety - React-Core - ReactCommon/turbomodule/core - - React-RCTBlob (0.71.3): + - React-RCTBlob (0.71.12): - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-Codegen (= 0.71.3) - - React-Core/RCTBlobHeaders (= 0.71.3) - - React-Core/RCTWebSocket (= 0.71.3) - - React-jsi (= 0.71.3) - - React-RCTNetwork (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTImage (0.71.3): + - React-Codegen (= 0.71.12) + - React-Core/RCTBlobHeaders (= 0.71.12) + - React-Core/RCTWebSocket (= 0.71.12) + - React-jsi (= 0.71.12) + - React-RCTNetwork (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTImage (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.3) - - React-Codegen (= 0.71.3) - - React-Core/RCTImageHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - React-RCTNetwork (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTLinking (0.71.3): - - React-Codegen (= 0.71.3) - - React-Core/RCTLinkingHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTNetwork (0.71.3): + - RCTTypeSafety (= 0.71.12) + - React-Codegen (= 0.71.12) + - React-Core/RCTImageHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - React-RCTNetwork (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTLinking (0.71.12): + - React-Codegen (= 0.71.12) + - React-Core/RCTLinkingHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTNetwork (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.3) - - React-Codegen (= 0.71.3) - - React-Core/RCTNetworkHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTSettings (0.71.3): + - RCTTypeSafety (= 0.71.12) + - React-Codegen (= 0.71.12) + - React-Core/RCTNetworkHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTSettings (0.71.12): - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.3) - - React-Codegen (= 0.71.3) - - React-Core/RCTSettingsHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-RCTText (0.71.3): - - React-Core/RCTTextHeaders (= 0.71.3) - - React-RCTVibration (0.71.3): + - RCTTypeSafety (= 0.71.12) + - React-Codegen (= 0.71.12) + - React-Core/RCTSettingsHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-RCTText (0.71.12): + - React-Core/RCTTextHeaders (= 0.71.12) + - React-RCTVibration (0.71.12): - RCT-Folly (= 2021.07.22.00) - - React-Codegen (= 0.71.3) - - React-Core/RCTVibrationHeaders (= 0.71.3) - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/core (= 0.71.3) - - React-runtimeexecutor (0.71.3): - - React-jsi (= 0.71.3) - - ReactCommon/turbomodule/bridging (0.71.3): + - React-Codegen (= 0.71.12) + - React-Core/RCTVibrationHeaders (= 0.71.12) + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/core (= 0.71.12) + - React-runtimeexecutor (0.71.12): + - React-jsi (= 0.71.12) + - ReactCommon/turbomodule/bridging (0.71.12): - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.3) - - React-Core (= 0.71.3) - - React-cxxreact (= 0.71.3) - - React-jsi (= 0.71.3) - - React-logger (= 0.71.3) - - React-perflogger (= 0.71.3) - - ReactCommon/turbomodule/core (0.71.3): + - React-callinvoker (= 0.71.12) + - React-Core (= 0.71.12) + - React-cxxreact (= 0.71.12) + - React-jsi (= 0.71.12) + - React-logger (= 0.71.12) + - React-perflogger (= 0.71.12) + - ReactCommon/turbomodule/core (0.71.12): - DoubleConversion - glog - hermes-engine - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.3) - - React-Core (= 0.71.3) - - React-cxxreact (= 0.71.3) - - React-jsi (= 0.71.3) - - React-logger (= 0.71.3) - - React-perflogger (= 0.71.3) + - React-callinvoker (= 0.71.12) + - React-Core (= 0.71.12) + - React-cxxreact (= 0.71.12) + - React-jsi (= 0.71.12) + - React-logger (= 0.71.12) + - React-perflogger (= 0.71.12) + - RNSVG (13.11.0): + - React-Core - SocketRocket (0.6.1) - Yoga (1.14.0) - YogaKit (1.18.1): @@ -482,6 +484,7 @@ DEPENDENCIES: - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - RNSVG (from `../node_modules/react-native-svg`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: @@ -572,6 +575,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" ReactCommon: :path: "../node_modules/react-native/ReactCommon" + RNSVG: + :path: "../node_modules/react-native-svg" Yoga: :path: "../node_modules/react-native/ReactCommon/yoga" @@ -579,8 +584,8 @@ SPEC CHECKSUMS: boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 - FBLazyVector: 60195509584153283780abdac5569feffb8f08cc - FBReactNativeSpec: 9c191fb58d06dc05ab5559a5505fc32139e9e4a2 + FBLazyVector: 4eb7ee83e8d0ad7e20a829485295ff48823c4e4c + FBReactNativeSpec: b24809f97ae83c786928d56b732957195b4fa390 Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 @@ -592,40 +597,41 @@ SPEC CHECKSUMS: FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - hermes-engine: 38bfe887e456b33b697187570a08de33969f5db7 + hermes-engine: b60ebc812e0179a612d8146ac54730d533c804a2 ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 - RCTRequired: bec48f07daf7bcdc2655a0cde84e07d24d2a9e2a - RCTTypeSafety: 171394eebacf71e1cfad79dbfae7ee8fc16ca80a - React: d7433ccb6a8c36e4cbed59a73c0700fc83c3e98a - React-callinvoker: 15f165009bd22ae829b2b600e50bcc98076ce4b8 - React-Codegen: b5910000eaf1e0c2f47d29be6f82f5f1264420d7 - React-Core: b6f2f78d580a90b83fd7b0d1c6911c799f6eac82 - React-CoreModules: e0cbc1a4f4f3f60e23c476fef7ab37be363ea8c1 - React-cxxreact: c87f3f124b2117d00d410b35f16c2257e25e50fa - React-hermes: c64ca6bdf16a7069773103c9bedaf30ec90ab38f - React-jsi: 39729361645568e238081b3b3180fbad803f25a4 - React-jsiexecutor: 515b703d23ffadeac7687bc2d12fb08b90f0aaa1 - React-jsinspector: 9f7c9137605e72ca0343db4cea88006cb94856dd - React-logger: 957e5dc96d9dbffc6e0f15e0ee4d2b42829ff207 - react-native-voice-processor: 7504bbbf53974ef57a184b0cf814873cf5e4a2a6 - React-perflogger: af8a3d31546077f42d729b949925cc4549f14def - React-RCTActionSheet: 57cc5adfefbaaf0aae2cf7e10bccd746f2903673 - React-RCTAnimation: 11c61e94da700c4dc915cf134513764d87fc5e2b - React-RCTAppDelegate: c3980adeaadcfd6cb495532e928b36ac6db3c14a - React-RCTBlob: ccc5049d742b41971141415ca86b83b201495695 - React-RCTImage: 7a9226b0944f1e76e8e01e35a9245c2477cdbabb - React-RCTLinking: bbe8cc582046a9c04f79c235b73c93700263e8b4 - React-RCTNetwork: fc2ca322159dc54e06508d4f5c3e934da63dc013 - React-RCTSettings: f1e9db2cdf946426d3f2b210e4ff4ce0f0d842ef - React-RCTText: 1c41dd57e5d742b1396b4eeb251851ce7ff0fca1 - React-RCTVibration: 5199a180d04873366a83855de55ac33ce60fe4d5 - React-runtimeexecutor: 7bf0dafc7b727d93c8cb94eb00a9d3753c446c3e - ReactCommon: 6f65ea5b7d84deb9e386f670dd11ce499ded7b40 + RCTRequired: 4db5e3e18b906377a502da5b358ff159ba4783ed + RCTTypeSafety: 6c1a8aed043050de0d537336c95cd1be7b66c272 + React: 214e77358d860a3ed707fede9088e7c00663a087 + React-callinvoker: 8fc1c79c26fbcadce2a5d4a3cb4b2ced2dec3436 + React-Codegen: 1517e1a59c594e6b5661d3d054209e838baa4fa7 + React-Core: ea541085ca5be10b2be289c7d82eba368b5c4900 + React-CoreModules: d9680e1d551eef1dd764df736a473cf25f701070 + React-cxxreact: 0792e80e291d086b2cf588410f6bc6e752bc1d83 + React-hermes: 0b1bba58112cb7421f1166d527a1a05489f48dbc + React-jsi: 1e41088515c4273ef5b118575337df4671851430 + React-jsiexecutor: 509cd947c28834614808ce056ee8eb700a0662aa + React-jsinspector: ec4dcbfb1f4e72f04f826a0301eceee5fa7ca540 + React-logger: 35538accacf2583693fbc3ee8b53e69a1776fcee + react-native-voice-processor: 93a1ac2add2baff144b0895ff48d72dbe6439eba + React-perflogger: 75b0e25075c67565a830985f3c373e2eae5389e0 + React-RCTActionSheet: a0c3e916b327e297d124d9ebe8b0c721840ee04d + React-RCTAnimation: 3da7025801d7bf0f8cfd94574d6278d5b82a8b88 + React-RCTAppDelegate: f74a567e0bc905aaff66d47ab30e6548f727549c + React-RCTBlob: 53252ebabe7777fd1c440a34546c64e16b162908 + React-RCTImage: e230761bd34d71362dd8b3d51b5cd72674935aa0 + React-RCTLinking: 3294b1b540005628168e5a341963b0eddc3932e8 + React-RCTNetwork: 00c6b2215e54a9fb015c53a5e02b0a852dbb8568 + React-RCTSettings: 2e7e4964f45e9b24c6c32ad30b6ab2ef4a7e2ffc + React-RCTText: a9c712b13cab90e1432e0ad113edc8bdbc691248 + React-RCTVibration: a283fefb8cc29d9740a7ff2e87f72ad10f25a433 + React-runtimeexecutor: 7902246857a4ead4166869e6c42d4df329ff721d + ReactCommon: a6d1c76b9e10b439e41db225263341240e1cda9f + RNSVG: 03e4d258ca355d7836a0a5dd4d4dc63c1eb49cbb SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - Yoga: 5ed1699acbba8863755998a4245daa200ff3817b + Yoga: 39310a10944fc864a7550700de349183450f8aaa YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: f0fe737bda985827849004326fc765e128262743 diff --git a/example/package.json b/example/package.json index 9cfc552..d83dbac 100644 --- a/example/package.json +++ b/example/package.json @@ -13,7 +13,7 @@ "dependencies": { "react": "18.2.0", "react-native": "0.71.12", - "react-native-svg": "^13.11.0" + "react-native-svg": "^14.1.0" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/example/yarn.lock b/example/yarn.lock index 43c2935..1af6a08 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -4032,10 +4032,10 @@ react-native-gradle-plugin@^0.71.19: resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.19.tgz#3379e28341fcd189bc1f4691cefc84c1a4d7d232" integrity sha512-1dVk9NwhoyKHCSxcrM6vY6cxmojeATsBobDicX0ZKr7DgUF2cBQRTKsimQFvzH8XhOVXyH8p4HyDSZNIFI8OlQ== -react-native-svg@^13.11.0: - version "13.11.0" - resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-13.11.0.tgz#90be2834a358351a76a57834941cb79183beb6b2" - integrity sha512-ApMp0t7NQh85BNq66nfN1/l8pwkj1Lx8Y+ErmBmZ0Oado3DSd+o/Fx/6Jm3GmBkmXl62t6Et0FHj1NYxNQw64w== +react-native-svg@^14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-14.1.0.tgz#7903bddd3c71bf3a8a503918253c839e6edaa724" + integrity sha512-HeseElmEk+AXGwFZl3h56s0LtYD9HyGdrpg8yd9QM26X+d7kjETrRQ9vCjtxuT5dCZEIQ5uggU1dQhzasnsCWA== dependencies: css-select "^5.1.0" css-tree "^1.1.3" diff --git a/ios/VoiceProcessor.swift b/ios/VoiceProcessor.swift index 35f9541..b936c9f 100644 --- a/ios/VoiceProcessor.swift +++ b/ios/VoiceProcessor.swift @@ -1,5 +1,5 @@ // -// Copyright 2020-2023 Picovoice Inc. +// Copyright 2020-2024 Picovoice Inc. // // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. @@ -22,24 +22,28 @@ class PvVoiceProcessor: RCTEventEmitter { private var settingsLock = NSLock() private var isSettingsErrorReported = false - private let FRAME_EMITTER_KEY = "frame_sent" - private let ERROR_EMITTER_KEY = "error_sent" + private let frameEmitterKey = "frame_sent" + private let errorEmitterKey = "error_sent" public override init() { super.init() voiceProcessor.addFrameListener(VoiceProcessorFrameListener({ frame in - self.sendEvent(withName: self.FRAME_EMITTER_KEY, body: Array(frame)) + DispatchQueue.main.async { + self.sendEvent(withName: self.frameEmitterKey, body: Array(frame)) + } })) voiceProcessor.addErrorListener(VoiceProcessorErrorListener({ error in - self.sendEvent(withName: self.ERROR_EMITTER_KEY, body: error.errorDescription) + DispatchQueue.main.async { + self.sendEvent(withName: self.errorEmitterKey, body: error.errorDescription) + } })) } override func supportedEvents() -> [String]! { [ - FRAME_EMITTER_KEY, - ERROR_EMITTER_KEY + frameEmitterKey, + errorEmitterKey ] } @@ -49,8 +53,8 @@ class PvVoiceProcessor: RCTEventEmitter { @objc override func constantsToExport() -> [AnyHashable: Any] { [ - "FRAME_EMITTER_KEY": FRAME_EMITTER_KEY, - "ERROR_EMITTER_KEY": ERROR_EMITTER_KEY + "FRAME_EMITTER_KEY": frameEmitterKey, + "ERROR_EMITTER_KEY": errorEmitterKey ] } @@ -117,7 +121,7 @@ class PvVoiceProcessor: RCTEventEmitter { AVAudioSession.sharedInstance().category != AVAudioSession.Category.playAndRecord { if !isSettingsErrorReported { self.sendEvent( - withName: ERROR_EMITTER_KEY, + withName: errorEmitterKey, body: "Audio settings have been changed and Picovoice is no longer receiving microphone audio.") isSettingsErrorReported = true } diff --git a/package.json b/package.json index fd62b24..89b0b6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@picovoice/react-native-voice-processor", - "version": "1.2.0", + "version": "1.2.2", "description": "A library for real-time voice processing in React Native.", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -20,6 +20,7 @@ "!android/gradlew", "!android/gradlew.bat", "!android/local.properties", + "!test", "!**/__tests__", "!**/__fixtures__", "!**/__mocks__", diff --git a/resources/.test/gradle_6.5/MainActivity.java b/resources/.test/gradle_6.5/MainActivity.java new file mode 100644 index 0000000..d3acb92 --- /dev/null +++ b/resources/.test/gradle_6.5/MainActivity.java @@ -0,0 +1,15 @@ +package ai.picovoice.reactnative.voiceprocessorexample; + +import com.facebook.react.ReactActivity; + +public class MainActivity extends ReactActivity { + + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "VoiceProcessorExample"; + } +} \ No newline at end of file diff --git a/resources/.test/gradle_6.5/MainApplication.java b/resources/.test/gradle_6.5/MainApplication.java new file mode 100644 index 0000000..9d476fb --- /dev/null +++ b/resources/.test/gradle_6.5/MainApplication.java @@ -0,0 +1,47 @@ +package ai.picovoice.reactnative.voiceprocessorexample; + +import android.app.Application; +import android.content.Context; +import com.facebook.react.PackageList; +import com.facebook.react.ReactApplication; +import com.facebook.react.ReactNativeHost; +import com.facebook.react.ReactPackage; +import com.facebook.react.ReactInstanceManager; +import com.facebook.soloader.SoLoader; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +public class MainApplication extends Application implements ReactApplication { + + private final ReactNativeHost mReactNativeHost = + new ReactNativeHost(this) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } + + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + + return packages; + } + + @Override + protected String getJSMainModuleName() { + return "index"; + } + }; + + @Override + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; + } + + @Override + public void onCreate() { + super.onCreate(); + SoLoader.init(this, /* native exopackage */ false); + } +} \ No newline at end of file diff --git a/resources/.test/gradle_6.5/app.build.gradle b/resources/.test/gradle_6.5/app.build.gradle new file mode 100644 index 0000000..85cef80 --- /dev/null +++ b/resources/.test/gradle_6.5/app.build.gradle @@ -0,0 +1,215 @@ +apply plugin: "com.android.application" + +import com.android.build.OutputFile + +/** + * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets + * and bundleReleaseJsAndAssets). + * These basically call `react-native bundle` with the correct arguments during the Android build + * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the + * bundle directly from the development server. Below you can see all the possible configurations + * and their defaults. If you decide to add a configuration block, make sure to add it before the + * `apply from: "../../node_modules/react-native/react.gradle"` line. + * + * project.ext.react = [ + * // the name of the generated asset file containing your JS bundle + * bundleAssetName: "index.android.bundle", + * + * // the entry file for bundle generation + * entryFile: "index.android.js", + * + * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format + * bundleCommand: "ram-bundle", + * + * // whether to bundle JS and assets in debug mode + * bundleInDebug: false, + * + * // whether to bundle JS and assets in release mode + * bundleInRelease: true, + * + * // whether to bundle JS and assets in another build variant (if configured). + * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants + * // The configuration property can be in the following formats + * // 'bundleIn${productFlavor}${buildType}' + * // 'bundleIn${buildType}' + * // bundleInFreeDebug: true, + * // bundleInPaidRelease: true, + * // bundleInBeta: true, + * + * // whether to disable dev mode in custom build variants (by default only disabled in release) + * // for VoiceProcessorExample: to disable dev mode in the staging build type (if configured) + * devDisabledInStaging: true, + * // The configuration property can be in the following formats + * // 'devDisabledIn${productFlavor}${buildType}' + * // 'devDisabledIn${buildType}' + * + * // the root of your project, i.e. where "package.json" lives + * root: "../../", + * + * // where to put the JS bundle asset in debug mode + * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", + * + * // where to put the JS bundle asset in release mode + * jsBundleDirRelease: "$buildDir/intermediates/assets/release", + * + * // where to put drawable resources / React Native assets, e.g. the ones you use via + * // require('./image.png')), in debug mode + * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", + * + * // where to put drawable resources / React Native assets, e.g. the ones you use via + * // require('./image.png')), in release mode + * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", + * + * // by default the gradle tasks are skipped if none of the JS files or assets change; this means + * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to + * // date; if you have any other folders that you want to ignore for performance reasons (gradle + * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ + * // for VoiceProcessorExample, you might want to remove it from here. + * inputExcludes: ["android/**", "ios/**"], + * + * // override which node gets called and with what additional arguments + * nodeExecutableAndArgs: ["node"], + * + * // supply additional arguments to the packager + * extraPackagerArgs: [] + * ] + */ + +project.ext.react = [ + enableHermes: false, // clean and rebuild if changing +] + +apply from: "../../node_modules/react-native/react.gradle" + +/** + * Set this to true to create two separate APKs instead of one: + * - An APK that only works on ARM devices + * - An APK that only works on x86 devices + * The advantage is the size of the APK is reduced by about 4MB. + * Upload all the APKs to the Play Store and people will download + * the correct one based on the CPU architecture of their device. + */ +def enableSeparateBuildPerCPUArchitecture = false + +/** + * Run Proguard to shrink the Java bytecode in release builds. + */ +def enableProguardInReleaseBuilds = false + +/** + * The preferred build flavor of JavaScriptCore. + * + * For VoiceProcessorExample, to use the international variant, you can use: + * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` + * + * The international variant includes ICU i18n library and necessary data + * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that + * give correct results when using with locales other than en-US. Note that + * this variant is about 6MiB larger per architecture than default. + */ +def jscFlavor = 'org.webkit:android-jsc:+' + +/** + * Whether to enable the Hermes VM. + * + * This should be set on project.ext.react and mirrored here. If it is not set + * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode + * and the benefits of using Hermes will therefore be sharply reduced. + */ +def enableHermes = project.ext.react.get("enableHermes", false); + +android { + compileSdkVersion rootProject.ext.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId "ai.picovoice.reactnativevoiceprocessordemo" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + } + splits { + abi { + reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK + include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + } + } + signingConfigs { + debug { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } + } + buildTypes { + debug { + signingConfig signingConfigs.debug + } + release { + // Caution! In production, you need to generate your own keystore file. + // see https://facebook.github.io/react-native/docs/signed-apk-android. + signingConfig signingConfigs.debug + minifyEnabled enableProguardInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + } + } + // applicationVariants are e.g. debug, release + applicationVariants.all { variant -> + variant.outputs.each { output -> + // For each separate APK per architecture, set a unique version code as described here: + // https://developer.android.com/studio/build/configure-apk-splits.html + def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] + def abi = output.getFilter(OutputFile.ABI) + if (abi != null) { // null for the universal-debug, universal-release variants + output.versionCodeOverride = + versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + } + + } + } + + packagingOptions { + pickFirst "lib/armeabi-v7a/libc++_shared.so" + pickFirst "lib/arm64-v8a/libc++_shared.so" + pickFirst "lib/x86/libc++_shared.so" + pickFirst "lib/x86_64/libc++_shared.so" + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" // From node_modules + + + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { + exclude group:'com.facebook.fbjni' + } + debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { + exclude group:'com.facebook.flipper' + } + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { + exclude group:'com.facebook.flipper' + } + + if (enableHermes) { + def hermesPath = "../../node_modules/hermes-engine/android/"; + debugImplementation files(hermesPath + "hermes-debug.aar") + releaseImplementation files(hermesPath + "hermes-release.aar") + } else { + implementation jscFlavor + } + + implementation project(':reactnativevoiceprocessor') +} + +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) \ No newline at end of file diff --git a/resources/.test/gradle_6.5/build.gradle b/resources/.test/gradle_6.5/build.gradle new file mode 100644 index 0000000..6aa4898 --- /dev/null +++ b/resources/.test/gradle_6.5/build.gradle @@ -0,0 +1,49 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext { + buildToolsVersion = "30.0.3" + minSdkVersion = 21 + compileSdkVersion = 33 + targetSdkVersion = 33 + } + repositories { + google() + mavenCentral() + } + + def localProperties = new Properties() + def localPropertiesFile = rootProject.file('local.properties') + if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } + } + + def agpVersion = localProperties.getProperty('agpVersion') + if (agpVersion == null) { + agpVersion = '7.4.2' + } + + dependencies { + classpath "com.android.tools.build:gradle:$agpVersion" + } +} + +allprojects { + repositories { + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url("$rootDir/../node_modules/react-native/android") + } + maven { + // Android JSC is installed from npm + url("$rootDir/../node_modules/jsc-android/dist") + } + + google() + jcenter() + maven { url 'https://www.jitpack.io' } + } +} \ No newline at end of file diff --git a/resources/.test/gradle_6.5/copy.sh b/resources/.test/gradle_6.5/copy.sh new file mode 100755 index 0000000..03473ef --- /dev/null +++ b/resources/.test/gradle_6.5/copy.sh @@ -0,0 +1,5 @@ +cp app.build.gradle ../../../example/android/app/build.gradle +cp build.gradle ../../../example/android/build.gradle +cp settings.gradle ../../../example/android/settings.gradle +cp MainActivity.java ../../../example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainActivity.java +cp MainApplication.java ../../../example/android/app/src/main/java/ai/picovoice/reactnative/voiceprocessorexample/MainApplication.java \ No newline at end of file diff --git a/resources/.test/gradle_6.5/settings.gradle b/resources/.test/gradle_6.5/settings.gradle new file mode 100644 index 0000000..b11e29f --- /dev/null +++ b/resources/.test/gradle_6.5/settings.gradle @@ -0,0 +1,6 @@ +rootProject.name = 'VoiceProcessorExample' +apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) +include ':app' + +include ':reactnativevoiceprocessor' +project(':reactnativevoiceprocessor').projectDir = new File(rootProject.projectDir, '../../android') \ No newline at end of file diff --git a/resources/.test/gradle_8.2/copy.sh b/resources/.test/gradle_8.2/copy.sh new file mode 100755 index 0000000..4e9fb55 --- /dev/null +++ b/resources/.test/gradle_8.2/copy.sh @@ -0,0 +1 @@ +cp settings.gradle ../../../example/android/settings.gradle \ No newline at end of file diff --git a/resources/.test/gradle_8.2/settings.gradle b/resources/.test/gradle_8.2/settings.gradle new file mode 100644 index 0000000..fda01a0 --- /dev/null +++ b/resources/.test/gradle_8.2/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'VoiceProcessorExample' +apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) +include ':app' +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/test/VoiceProcessorTestApp/Tests.ts b/test/VoiceProcessorTestApp/Tests.ts index 0cd00af..278c8f4 100644 --- a/test/VoiceProcessorTestApp/Tests.ts +++ b/test/VoiceProcessorTestApp/Tests.ts @@ -31,7 +31,6 @@ async function basicTest(): Promise { testName: 'Basic test', success: false, }; - console.log('ho'); let frameCount = 0; let errorCount = 0; diff --git a/test/VoiceProcessorTestApp/android/app/build.gradle b/test/VoiceProcessorTestApp/android/app/build.gradle index 6e3ccec..f2654e0 100644 --- a/test/VoiceProcessorTestApp/android/app/build.gradle +++ b/test/VoiceProcessorTestApp/android/app/build.gradle @@ -89,11 +89,19 @@ def reactNativeArchitectures() { } android { - ndkVersion rootProject.ext.ndkVersion + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() >= 7) { + namespace "ai.picovoice.voiceprocessortestapp" + } + + if (agpVersion.tokenize('.')[0].toInteger() >= 8) { + buildFeatures { + buildConfig = true + } + } compileSdkVersion rootProject.ext.compileSdkVersion - namespace "ai.picovoice.voiceprocessortestapp" defaultConfig { applicationId "ai.picovoice.voiceprocessortestapp" minSdkVersion rootProject.ext.minSdkVersion diff --git a/test/VoiceProcessorTestApp/android/app/src/main/AndroidManifest.xml b/test/VoiceProcessorTestApp/android/app/src/main/AndroidManifest.xml index 2285f27..43334af 100644 --- a/test/VoiceProcessorTestApp/android/app/src/main/AndroidManifest.xml +++ b/test/VoiceProcessorTestApp/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ - + diff --git a/test/VoiceProcessorTestApp/android/build.gradle b/test/VoiceProcessorTestApp/android/build.gradle index 63cfc6b..eaf847a 100644 --- a/test/VoiceProcessorTestApp/android/build.gradle +++ b/test/VoiceProcessorTestApp/android/build.gradle @@ -1,21 +1,30 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { ext { buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 - - // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. - ndkVersion = "23.1.7779620" } repositories { google() mavenCentral() } + + def localProperties = new Properties() + def localPropertiesFile = rootProject.file('local.properties') + if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } + } + + def agpVersion = localProperties.getProperty('agpVersion') + if (agpVersion == null) { + agpVersion = '7.4.2' + } + dependencies { - classpath("com.android.tools.build:gradle:7.3.1") + classpath("com.android.tools.build:gradle:$agpVersion") classpath("com.facebook.react:react-native-gradle-plugin") } } diff --git a/test/VoiceProcessorTestApp/android/gradle/wrapper/gradle-wrapper.properties b/test/VoiceProcessorTestApp/android/gradle/wrapper/gradle-wrapper.properties index 8fad3f5..2ec77e5 100644 --- a/test/VoiceProcessorTestApp/android/gradle/wrapper/gradle-wrapper.properties +++ b/test/VoiceProcessorTestApp/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/tsconfig.build.json b/tsconfig.build.json index 999d3f3..114f290 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,5 +1,5 @@ { "extends": "./tsconfig", - "exclude": ["example"] + "exclude": ["example", "test"] } diff --git a/tsconfig.json b/tsconfig.json index b6c9d93..fc4244d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,5 +24,8 @@ "skipLibCheck": true, "strict": true, "target": "esnext" - } + }, + "exclude": [ + "test" + ] }