MrHertal / react-native-twilio-phone

Twilio Voice React Native module.
MIT License
154 stars 66 forks source link

After updating to Android 14, the outgoing call on Google Pixel stopped working #127

Open AlekseiEDT opened 2 weeks ago

AlekseiEDT commented 2 weeks ago

Hello everyone. I recently upgraded the SDK version to 34 (android 14) and after that I get a constant error on the Google Pixel model, when user make an outgoing call, the call ends immediately and the application closes. This error only occurs with Google Pixel at the moment. The error started appearing after adding these changes: in android/app/build.gradle `dependencies { implementation 'com.google.android.play:asset-delivery:2.2.2' implementation 'com.google.android.play:feature-delivery:2.1.0' implementation 'com.google.android.play:review:2.0.1' implementation 'com.google.android.play:app-update:2.1.0'

implementation 'com.google.android.play:asset-delivery-ktx:2.2.2'
implementation 'com.google.android.play:feature-delivery-ktx:2.1.0'
implementation 'com.google.android.play:review-ktx:2.0.1'
implementation 'com.google.android.play:app-update-ktx:2.1.0'
...
}
`

mine android/app/build.gradle file ` apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services'

  import com.android.build.OutputFile
  import org.apache.tools.ant.taskdefs.condition.Os

  project.ext.react = [
      enableHermes: false,  // clean and rebuild if changing
  ]

  apply from: "../../node_modules/react-native/react.gradle"
  apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
  def enableSeparateBuildPerCPUArchitecture = false

  def enableProguardInReleaseBuilds = false

  def jscFlavor = 'org.webkit:android-jsc:+'

  def enableHermes = project.ext.react.get("enableHermes", false);

  def reactNativeArchitectures() {
      def value = project.getProperties().get("reactNativeArchitectures")
      return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
  }

  android {
      ndkVersion rootProject.ext.ndkVersion

      compileSdkVersion rootProject.ext.compileSdkVersion

      defaultConfig {
          applicationId 'com.frontoffice_taxinfonet'
          minSdkVersion rootProject.ext.minSdkVersion
          targetSdkVersion rootProject.ext.targetSdkVersion
          versionCode 56
          versionName "1.2.4.4"
          multiDexEnabled true
          buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

          if (isNewArchitectureEnabled()) {
              // We configure the NDK build only if you decide to opt-in for the New Architecture.
              externalNativeBuild {
                  ndkBuild {
                      arguments "APP_PLATFORM=android-21",
                          "APP_STL=c++_shared",
                          "NDK_TOOLCHAIN_VERSION=clang",
                          "GENERATED_SRC_DIR=$buildDir/generated/source",
                          "PROJECT_BUILD_DIR=$buildDir",
                          "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
                          "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
                      cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
                      cppFlags "-std=c++17"
                      // Make sure this target name is the same you specify inside the
                      // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
                      targets "app_front_appmodules"
                      // Fix for windows limit on number of character in file paths and in command lines
                      if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                          arguments "NDK_APP_SHORT_COMMANDS=true"
                      }
                  }
              }
              if (!enableSeparateBuildPerCPUArchitecture) {
                  ndk {
                      abiFilters (*reactNativeArchitectures())
                  }
              }
          }
      }

      if (isNewArchitectureEnabled()) {
          // We configure the NDK build only if you decide to opt-in for the New Architecture.
          externalNativeBuild {
              ndkBuild {
                  path "$projectDir/src/main/jni/Android.mk"
              }
          }
          def reactAndroidProjectDir = project(':ReactAndroid').projectDir
          def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
              dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
              from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
              into("$buildDir/react-ndk/exported")
          }
          def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
              dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
              from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
              into("$buildDir/react-ndk/exported")
          }
          afterEvaluate {
              // If you wish to add a custom TurboModule or component locally,
              // you should uncomment this line.
              // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
              preDebugBuild.dependsOn(packageReactNdkDebugLibs)
              preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)

              // Due to a bug inside AGP, we have to explicitly set a dependency
              // between configureNdkBuild* tasks and the preBuild tasks.
              // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
              configureNdkBuildRelease.dependsOn(preReleaseBuild)
              configureNdkBuildDebug.dependsOn(preDebugBuild)
              reactNativeArchitectures().each { architecture ->
                  tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
                      dependsOn("preDebugBuild")
                  }
                  tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
                      dependsOn("preReleaseBuild")
                  }
              }
          }
      }

      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include (*reactNativeArchitectures())
          }
      }
      signingConfigs {
          debug {
              storeFile file('debug.keystore')
              storePassword 'android'
              keyAlias 'androiddebugkey'
              keyPassword 'android'
          }
          release {
              if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                  storeFile file(MYAPP_UPLOAD_STORE_FILE)
                  storePassword MYAPP_UPLOAD_STORE_PASSWORD
                  keyAlias MYAPP_UPLOAD_KEY_ALIAS
                  keyPassword MYAPP_UPLOAD_KEY_PASSWORD
              }
          }
      }
      buildTypes {
          debug {
              signingConfig signingConfigs.debug
          }
          release {
              // Caution! In production, you need to generate your own keystore file.
              // see https://reactnative.dev/docs/signed-apk-android.
              signingConfig signingConfigs.release
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
          }
      }
      applicationVariants.all { variant ->
          variant.outputs.each { output ->
              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 =
                          defaultConfig.versionCode * 1000 + versionCodes.get(abi)
              }

          }
      }
  }

  dependencies {
      implementation 'com.google.android.play:asset-delivery:2.2.2'
      implementation 'com.google.android.play:feature-delivery:2.1.0'
      implementation 'com.google.android.play:review:2.0.1'
      implementation 'com.google.android.play:app-update:2.1.0'

      implementation 'com.google.android.play:asset-delivery-ktx:2.2.2'
      implementation 'com.google.android.play:feature-delivery-ktx:2.1.0'
      implementation 'com.google.android.play:review-ktx:2.0.1'
      implementation 'com.google.android.play:app-update-ktx:2.1.0'

      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation platform('com.google.firebase:firebase-bom:31.1.1')
      //noinspection GradleDynamicVersion
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation project(':react-native-gesture-handler')
      implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
      implementation 'com.android.support:support-annotations:28.0.0'
      implementation "androidx.annotation:annotation:1.3.0"
      implementation project(':react-native-notifications')
      implementation 'com.google.firebase:firebase-messaging:20.1.0'
      implementation project(":react-native-haptic-feedback")

      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'
          exclude group:'com.squareup.okhttp3', module:'okhttp'
      }

      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(':react-native-callkeep')
  }

  if (isNewArchitectureEnabled()) {
      configurations.all {
          resolutionStrategy.dependencySubstitution {
              substitute(module("com.facebook.react:react-native"))
                      .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
          }
      }
  }

  task copyDownloadableDepsToLibs(type: Copy) {
      from configurations.implementation
      into 'libs'
  }

  apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
  apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
  def isNewArchitectureEnabled() {
      return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
  }

`

mine android/build.gradle file ` import org.apache.tools.ant.taskdefs.condition.Os

def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 34

      if (System.properties['os.arch'] == "aarch64") {
          ndkVersion = "24.0.8215888"
      } else {
          ndkVersion = "21.4.7075529"
      }
  }
  repositories {

      google()
      mavenCentral()
  }
  dependencies {
      classpath('com.android.tools.build:gradle:7.1.3')
      classpath("com.facebook.react:react-native-gradle-plugin")
      classpath("de.undercouch:gradle-download-task:4.1.2")
      classpath('com.google.gms:google-services:4.3.13')
  }

}

allprojects { configurations.all { resolutionStrategy { force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION } } repositories { maven { url("$rootDir/../node_modules/react-native/android") } maven { url("$rootDir/../node_modules/jsc-android/dist") } mavenCentral { content { excludeGroup "com.facebook.react" } } google() jcenter() maven { url 'https://www.jitpack.io' } } }

`

ilkinabdullayev commented 1 week ago

Hello, any log?