Skip to content

Commit

Permalink
Update for Android 14 compatibility (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
smuzani authored Jan 19, 2024
1 parent af1a710 commit 8612eb7
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 49 deletions.
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
compileSdk 34
defaultConfig {
applicationId "com.xendit.example"
targetSdkVersion 30
targetSdkVersion 34


versionCode 1
Expand All @@ -14,11 +14,12 @@ android {
flavorDimensions "api"
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}


productFlavors {
product{
dimension "api"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application
Expand All @@ -15,7 +16,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.xendit.example.MainActivity">
<activity android:name="com.xendit.example.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
83 changes: 44 additions & 39 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

group 'com.xendit'
version '3.8.5'
Expand Down Expand Up @@ -31,10 +31,10 @@ ext {
}

android {
compileSdkVersion 30
compileSdk 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 34
versionCode 1
versionName '3.8.5'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand All @@ -55,6 +55,10 @@ android {
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
Expand Down Expand Up @@ -102,7 +106,7 @@ dependencies {

publishing {
publications {
Production(MavenPublication) {
mavenJava(MavenPublication) {
artifact("$buildDir/outputs/aar/xendit-android-release.aar") // replace with your library name
groupId this.group
artifactId 'xendit-android' // replace with your library artifact id
Expand All @@ -129,12 +133,9 @@ publishing {

tasks.withType(Javadoc).all { enabled = false }

apply plugin: 'maven'
apply plugin: 'signing'

if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

Expand All @@ -144,7 +145,7 @@ if (project.hasProperty("android")) { // Android libraries
}
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
}
Expand All @@ -159,55 +160,59 @@ String ossrhUser = properties.getProperty('ossrh.username')
String ossrhPassword = properties.getProperty('ossrh.password')

signing {
sign configurations.archives
sign publishing.publications.mavenJava
}

uploadArchives {
repositories {
mavenDeployer {

beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUser, password: ossrhPassword)
}

snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUser, password: ossrhPassword)
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.findByName("release")

pom.project {
name bintrayName
packaging 'aar'
// optionally artifactId can be defined here
description libraryDescription
url siteUrl
groupId publishedGroupId
artifactId artifact
version libraryVersion

scm {
connection gitUrl
developerConnection gitUrl
url gitUrl
}
pom {
name = libraryName
description = libraryDescription
url = siteUrl

licenses {
license {
name licenseName
url licenseUrl
name = licenseName
url = licenseUrl
}
}

developers {
developer {
id developerId
name developerName
email developerEmail
id = developerId
name = developerName
email = developerEmail
}
}

scm {
connection = gitUrl
developerConnection = gitUrl
url = siteUrl
}
}
}
}
}

repositories {
maven {
name = "Sonatype"
url = version.endsWith('SNAPSHOT') ? "https://s01.oss.sonatype.org/content/repositories/snapshots/" : "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username ossrhUser
password ossrhPassword
}
}
}

nexusStaging {
serverUrl = 'https://s01.oss.sonatype.org/service/local/'
username = ossrhUser
Expand Down
19 changes: 16 additions & 3 deletions xendit-android/src/main/java/com/xendit/Xendit.java
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,12 @@ public void run() {
}

authenticationBroadcastReceiver = new AuthenticationBroadcastReceiver(authenticationCallback);
context.registerReceiver(authenticationBroadcastReceiver, new IntentFilter(ACTION_KEY));
// if version is over 33
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(authenticationBroadcastReceiver, new IntentFilter(ACTION_KEY), Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(authenticationBroadcastReceiver, new IntentFilter(ACTION_KEY));
}
}
});
}
Expand All @@ -816,7 +821,11 @@ public void run() {
}

tokenBroadcastReceiver = new TokenBroadcastReceiver(tokenCallback);
context.registerReceiver(tokenBroadcastReceiver, new IntentFilter(ACTION_KEY));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(tokenBroadcastReceiver, new IntentFilter(ACTION_KEY), Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(tokenBroadcastReceiver, new IntentFilter(ACTION_KEY));
}
}
});
}
Expand All @@ -830,7 +839,11 @@ public void run() {
}

authenticatedTokenBroadcastReceiver = new AuthenticatedTokenBroadcastReceiver(tokenCallback);
context.registerReceiver(authenticatedTokenBroadcastReceiver, new IntentFilter(ACTION_KEY));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(authenticatedTokenBroadcastReceiver, new IntentFilter(ACTION_KEY), Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(authenticatedTokenBroadcastReceiver, new IntentFilter(ACTION_KEY));
}
}
});
}
Expand Down

0 comments on commit 8612eb7

Please sign in to comment.