Skip to content

Android build fails due to deprecated jcenter() and outdated SDK configurationΒ #293

@Jaffar-Vali

Description

@Jaffar-Vali

Hi! πŸ‘‹

Firstly, thanks for maintaining react-native-tts β€” really appreciate the work πŸ™‚

Problem

react-native-tts@4.1.1 fails to build on modern React Native / Android
toolchains due to:

  • usage of jcenter() (deprecated and removed)
  • outdated Android Gradle Plugin assumptions
  • low compileSdk / targetSdk versions

Solution

Updated the Android library configuration to:

  • remove legacy buildscript {} block
  • replace jcenter() with google() + mavenCentral()
  • bump compileSdk / targetSdk to 34
  • enable Java 8 compatibility

This allows the library to build successfully with current
Android Gradle Plugin and React Native versions.

Below is the patch diff that resolved the issue:
diff --git a/node_modules/react-native-tts/android/build.gradle b/node_modules/react-native-tts/android/build.gradle
index dbbe046..4b568f2 100644
--- a/node_modules/react-native-tts/android/build.gradle
+++ b/node_modules/react-native-tts/android/build.gradle
@@ -2,31 +2,26 @@ def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

-buildscript {

  • repositories {
  •    jcenter()
    
  • }
  • dependencies {
  •    classpath 'com.android.tools.build:gradle:1.3.1'
    
  • }
    -}

apply plugin: 'com.android.library'

android {

  • compileSdkVersion safeExtGet('compileSdkVersion', 26)
  • buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
  • compileSdkVersion safeExtGet('compileSdkVersion', 34)

    defaultConfig {

  •    minSdkVersion safeExtGet('minSdkVersion', 16)
    
  •    targetSdkVersion safeExtGet('targetSdkVersion', 26)
    
  •    minSdkVersion safeExtGet('minSdkVersion', 21)
    
  •    targetSdkVersion safeExtGet('targetSdkVersion', 34)
       versionCode 1
       versionName "1.0"
    
    }
  • compileOptions {
  •    sourceCompatibility JavaVersion.VERSION_1_8
    
  •    targetCompatibility JavaVersion.VERSION_1_8
    
  • }
    }

repositories {

  • google()
    mavenCentral()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions