Skip to content

Commit

Permalink
Chore/update android sdk version (#112)
Browse files Browse the repository at this point in the history
* chore: update to Android SDK version 14

* update test library to compatible with api v34

* chore: updating dependencies

* chore: updating dependencies

* chore: updated outdated packages and resolve error

* chore: update build.gradle
  • Loading branch information
stephenthajeb authored Jan 23, 2024
1 parent 1369b0d commit 3df2eca
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 138 deletions.
30 changes: 17 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
apply plugin: 'com.android.application'

android {
namespace 'com.xendit.example'
compileSdk 34
defaultConfig {
applicationId "com.xendit.example"
targetSdkVersion 34


versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
flavorDimensions "api"
flavorDimensions.add("api")
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

Expand All @@ -37,25 +36,30 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildToolsVersion '34.0.0'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
implementation project(':xendit-android')

// App's dependencies, including test
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.annotation:annotation:1.7.1'

// Testing-only dependencies
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Optional -- UI testing with UI Automator
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
// Optional add hamcrest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.xendit.example;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;

import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.UiObjectNotFoundException;
import androidx.test.uiautomator.UiSelector;
import androidx.test.uiautomator.Until;

import android.widget.Button;

import org.hamcrest.CoreMatchers;
Expand All @@ -32,7 +35,7 @@ public class SampleAppDefaultTest {

private UiDevice mDevice;

private Context appContext = InstrumentationRegistry.getTargetContext();
private Context appContext = InstrumentationRegistry.getInstrumentation().getContext();

@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(
Expand All @@ -43,7 +46,7 @@ public class SampleAppDefaultTest {
* The target app package.
*/
private static final String TARGET_PACKAGE =
InstrumentationRegistry.getTargetContext().getPackageName();
InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName();

@Before
public void startActivityFromHomeScreen() {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xendit.example">
>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -19,7 +19,6 @@
<activity android:name="com.xendit.example.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -40,4 +39,4 @@
/>
</application>

</manifest>
</manifest>
22 changes: 9 additions & 13 deletions app/src/main/java/com/xendit/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,15 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.createTokenTextView_MainActivity:
startActivity(CreateTokenActivity.getLaunchIntent(this));
break;
case R.id.authenticationTextView_MainActivity:
startActivity(AuthenticationActivity.getLaunchIntent(this));
break;
case R.id.validationUtilTextView_MainActivity:
startActivity(ValidationUtilActivity.getLaunchIntent(this));
break;
case R.id.storeCVNTextView_MainActivity:
startActivity(StoreCvnActivity.getLaunchIntent(this));
break;
int id = view.getId();
if (id == R.id.createTokenTextView_MainActivity) {
startActivity(CreateTokenActivity.getLaunchIntent(this));
} else if (id == R.id.authenticationTextView_MainActivity) {
startActivity(AuthenticationActivity.getLaunchIntent(this));
} else if (id == R.id.validationUtilTextView_MainActivity) {
startActivity(ValidationUtilActivity.getLaunchIntent(this));
} else if (id == R.id.storeCVNTextView_MainActivity) {
startActivity(StoreCvnActivity.getLaunchIntent(this));
}
}

Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.2.1'
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
127 changes: 70 additions & 57 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

group 'com.xendit'
Expand Down Expand Up @@ -31,6 +32,7 @@ ext {
}

android {
namespace 'com.xendit'
compileSdk 34
defaultConfig {
minSdkVersion 21
Expand All @@ -55,24 +57,23 @@ android {
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
}
buildFeatures {
buildConfig = true
}
}

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.volley:volley:1.2.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.core:core:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10'
implementation 'androidx.annotation:annotation:1.7.1'
implementation 'androidx.core:core:1.12.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.snowplowanalytics:snowplow-android-tracker:2.1.1@aar'

// sentry
Expand All @@ -84,16 +85,16 @@ dependencies {

// Testing-only dependencies
// Required -- JUnit 4 framework
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
// Optional -- Robolectric environment
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'org.robolectric:robolectric:4.0-beta-1'
testImplementation "com.google.truth:truth:0.42"
androidTestImplementation "org.mockito:mockito-core:3.1.0"
androidTestImplementation "com.google.truth:truth:0.42"
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// retrofit
api 'com.squareup.retrofit2:retrofit:2.5.0'
Expand All @@ -104,35 +105,10 @@ dependencies {

}

publishing {
publications {
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
version this.version

pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')

// Iterate over the implementation dependencies (we don't want the test ones),
// adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}

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


if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
Expand All @@ -159,24 +135,27 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream(
String ossrhUser = properties.getProperty('ossrh.username')
String ossrhPassword = properties.getProperty('ossrh.password')

signing {
sign publishing.publications.mavenJava
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.findByName("release")

groupId publishedGroupId
artifactId artifact
version libraryVersion
groupId = 'com.xendit'
artifactId = 'xendit-sdk-android'
bintrayOrg = 'xendit'
bintrayRepo = 'android'

pom {
name = libraryName
name = bintrayName
packaging = 'aar'
description = libraryDescription
url = siteUrl

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

licenses {
license {
name = licenseName
Expand All @@ -191,28 +170,62 @@ publishing {
email = developerEmail
}
}
}
}

Production(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
version this.version

pom {
name = bintrayName
packaging = 'aar'
description = libraryDescription
url = siteUrl

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

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

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

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
repositories {
maven {
url = version.endsWith('SNAPSHOT') ? uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") : uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = ossrhUser
password = ossrhPassword
}
}
}
}

signing {
sign publishing.publications
}


nexusStaging {
serverUrl = 'https://s01.oss.sonatype.org/service/local/'
username = ossrhUser
Expand Down
Loading

0 comments on commit 3df2eca

Please sign in to comment.