Skip to content

Commit

Permalink
fix: make the android modules compatible with AGP 8 (#12371)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF authored Oct 20, 2023
2 parents 1497592 + 76ca2e8 commit 6bef5b8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 4 deletions.
14 changes: 14 additions & 0 deletions packages/amazon-cognito-identity-js/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import com.android.Version

def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersion >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'

buildscript {
repositories {
mavenCentral()
Expand All @@ -15,6 +20,10 @@ def safeExtGet(prop, fallback) {
}

android {
if (agpVersion >= 7) {
namespace "com.amazonaws"
}

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

Expand All @@ -24,6 +33,11 @@ android {
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile androidManifestPath
}
}
lintOptions {
abortOnError false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
15 changes: 15 additions & 0 deletions packages/rtn-push-notification/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import com.android.Version

def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersion >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'

buildscript {
def kotlin_version = rootProject.ext.has('kotlinVersion')
? rootProject.ext.get('kotlinVersion')
Expand Down Expand Up @@ -26,13 +31,23 @@ def getExtOrDefault(prop) {
}

android {
if (agpVersion >= 7) {
namespace 'com.amazonaws.amplify.rtnpushnotification'
}

compileSdkVersion getExtOrDefault('compileSdkVersion')

defaultConfig {
minSdkVersion getExtOrDefault('minSdkVersion')
targetSdkVersion getExtOrDefault('targetSdkVersion')
}

sourceSets {
main {
manifest.srcFile androidManifestPath
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws.amplify.rtnpushnotification">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
<activity
android:name=".PushNotificationLaunchActivity"
android:launchMode="singleInstance"
android:exported="false" />

<service android:name=".PushNotificationHeadlessTaskService" />

<service
android:name=".PushNotificationFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws.amplify.rtnpushnotification">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
Expand Down

0 comments on commit 6bef5b8

Please sign in to comment.