Skip to content

Commit

Permalink
#1455 | targetSdk 34
Browse files Browse the repository at this point in the history
- building using gradle 8 throws errors if any dependencies have package name specified in AndroidManifest.xml
-- Addressed by patching AndroidManifest.xml of each affected dependency to remove package and added namespace to corresponding build.gradle
-- For amazon-cognito-identity-js, addressed by upgrading dependency to a later patch version with this change
- react-native-vector-icons needed additional patching for other breaking issues in gradle 8 - oblador/react-native-vector-icons#1588
- react-native-video upgraded from 5.2.0 to 5.2.1 to fix TheWidlarzGroup/react-native-video#3160.
-- Changes in existing patch for 5.2.0 are already included in react-native-video release 5.2.1
- react-native upgraded from 0.72.3 to 0.72.8 to get fix for facebook/react-native#38256 which was causing crash on launch
-- Additionally, did an override of registerReceiver in MainApplication.java facebook/react-native#41288
  • Loading branch information
1t5j0y committed Jul 18, 2024
1 parent c1ed919 commit cf3f2d3
Show file tree
Hide file tree
Showing 47 changed files with 2,505 additions and 1,630 deletions.
19 changes: 2 additions & 17 deletions packages/openchs-android/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ def enableProguardInReleaseBuilds = true

android {
ndkVersion rootProject.ext.ndkVersion

dexOptions {
javaMaxHeapSize "3g"
}
namespace "com.openchs.client"

compileSdkVersion rootProject.ext.compileSdkVersion

Expand Down Expand Up @@ -223,31 +220,18 @@ android {
}

dependencies {
implementation project(':react-native-background-timer')
implementation project(':react-native-file-viewer')
implementation project(':react-native-keep-awake')
implementation project(':react-native-audio-recorder-player')
implementation project(':react-native-document-picker')
implementation project(':react-native-zip-archive')
implementation project(':react-native-webview')
implementation project(':@react-native-firebase_app')
implementation project(':@react-native-firebase_analytics')
implementation project(':react-native-immediate-phone-call')
implementation project(':amazon-cognito-identity-js')
implementation (project(':rn-fetch-blob')) {
exclude group: 'com.squareup.okhttp3'
}
implementation project(':react-native-image-picker')
implementation project(':react-native-fs')
implementation(project(':react-native-video')) {
exclude group: 'com.squareup.okhttp3'
}
implementation project(':bugsnag-react-native')
implementation project(':react-native-geolocation-service')
implementation project(':react-native-charts-wrapper')
implementation project(':react-native-vector-icons')
// implementation project(':react-native-i18n')
// implementation project(':realm')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}"
implementation project(':react-native-device-info')
Expand All @@ -257,6 +241,7 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01'
implementation 'org.jetbrains:annotations:16.0.2'

// required to avoid crash on Android 12 API 31
implementation 'androidx.work:work-runtime:2.8.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="33" tools:ignore="GoogleAppIndexingWarning" />
<application android:usesCleartextTraffic="true" tools:targetApi="34" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

import android.content.Context;
import android.util.Log;

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;
import com.facebook.react.*;
import com.facebook.soloader.SoLoader;

Expand All @@ -50,10 +54,9 @@ protected List<ReactPackage> getPackages() {
Class<?> aClass = Class.forName("com.openchsclient.TamperCheckPackage");
ReactPackage tamperCheckPackage = (ReactPackage) aClass.newInstance();
if (tamperCheckPackage != null) packages.add(tamperCheckPackage);
} catch(Exception e) {
} catch (Exception e) {
Log.i("MainApplication", e.toString());
}
finally {
} finally {
return packages;
}
}
Expand Down Expand Up @@ -85,4 +88,13 @@ public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
if (Build.VERSION.SDK_INT >= 34 && getApplicationInfo().targetSdkVersion >= 34) {
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
} else {
return super.registerReceiver(receiver, filter);
}
}

}
11 changes: 5 additions & 6 deletions packages/openchs-android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
buildscript {

ext {
buildToolsVersion = "33.0.0"
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 34
supportLibVersion = "1.2.0"
googlePlayServicesVersion = "16.0.0" //Without this the react-native-device-info crashes
kotlinVersion = '1.6.21'
Expand All @@ -24,7 +24,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.gms:google-services:4.4.2'
classpath 'de.undercouch:gradle-download-task:4.1.2'
classpath('com.facebook.react:react-native-gradle-plugin')
// NOTE: Do not place your application dependencies here; they belong
Expand Down Expand Up @@ -61,8 +61,7 @@ subprojects {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 33
// buildToolsVersion = "29.0.3"
compileSdkVersion = 34
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/openchs-android/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ hermesEnabled=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
AsyncStorage_useNextStorage=true
Binary file not shown.
7 changes: 4 additions & 3 deletions packages/openchs-android/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
20 changes: 0 additions & 20 deletions packages/openchs-android/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
rootProject.name = 'Avni'
include ':react-native-background-timer'
project(':react-native-background-timer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-timer/android')
include ':react-native-file-viewer'
project(':react-native-file-viewer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-viewer/android')
include ':react-native-keep-awake'
project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
include ':react-native-audio-recorder-player'
project(':react-native-audio-recorder-player').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-audio-recorder-player/android')
include ':react-native-document-picker'
project(':react-native-document-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-picker/android')
include ':react-native-zip-archive'
project(':react-native-zip-archive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zip-archive/android')
include ':react-native-background-job'
project(':react-native-background-job').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-job/android')
include ':react-native-background-worker'
project(':react-native-background-worker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-worker/android')
include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/app/android')
include ':@react-native-firebase_analytics'
project(':@react-native-firebase_analytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/analytics/android')
include ':react-native-immediate-phone-call'
project(':react-native-immediate-phone-call').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immediate-phone-call/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':amazon-cognito-identity-js'
project(':amazon-cognito-identity-js').projectDir = new File(rootProject.projectDir, '../node_modules/amazon-cognito-identity-js/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-image-picker'
Expand All @@ -33,14 +21,6 @@ include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':react-native-geolocation-service'
project(':react-native-geolocation-service').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geolocation-service/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
include ':bugsnag-react-native'
project(':bugsnag-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/bugsnag-react-native/android')
include ':react-native-charts-wrapper'
project(':react-native-charts-wrapper').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-charts-wrapper/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

Expand Down
Loading

0 comments on commit cf3f2d3

Please sign in to comment.