Skip to content

Commit 37e743b

Browse files
Merge pull request #66 from AppsFlyerSDK/development
Development
2 parents d3f36f4 + d99dfda commit 37e743b

File tree

20 files changed

+699
-110
lines changed

20 files changed

+699
-110
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI - Tests
2+
on:
3+
push:
4+
branches-ignore:
5+
- 'main'
6+
- 'releases/**'
7+
jobs:
8+
Tests:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up JDK
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: '11'
16+
- name: Setup Android SDK
17+
uses: android-actions/setup-android@v2
18+
- name: Make gradlew executable
19+
run: chmod +x ./gradlew
20+
- name: Run Tests
21+
run: ./gradlew test
22+
- name: Test Report
23+
uses: dorny/test-reporter@v1
24+
if: always()
25+
with:
26+
name: Test Results
27+
path: app/build/test-results/testDebugUnitTest/TEST-*.xml # Path to test results
28+
reporter: java-junit # Format of test results
29+
fail-on-error: true

RELEASENOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
### 6.10.1
4+
* Update Android SDK to v6.10.1
5+
* Added unit tests.
6+
* Added github workflows.
7+
38
### 6.8.2
49
* Update Android SDK to v6.8.2
510

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You can track installs, updates and sessions and also track additional in-app ev
2121

2222
---
2323

24-
Built with AppsFlyer Android SDK `v6.8.2`
24+
Built with AppsFlyer Android SDK `v6.10.1`
2525

2626
## Table of content
2727

app/build.gradle

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 26
4+
compileSdkVersion 32
55

66
defaultConfig {
77
minSdkVersion 14
8-
targetSdkVersion 26
8+
targetSdkVersion 32
99
versionCode 1
1010
versionName "1.0"
11+
testApplicationId "com.example.test"
12+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1113
}
1214
buildTypes {
1315
release {
@@ -19,15 +21,42 @@ android {
1921
sourceCompatibility JavaVersion.VERSION_1_8
2022
targetCompatibility JavaVersion.VERSION_1_8
2123
}
24+
25+
testOptions {
26+
unitTests {
27+
all {
28+
testLogging {
29+
exceptionFormat = "full"
30+
events "PASSED", "FAILED", "SKIPPED"
31+
}
32+
forkEvery 1
33+
}
34+
includeAndroidResources = true
35+
returnDefaultValues = true
36+
}
37+
}
2238
}
2339

2440
dependencies {
25-
implementation 'com.appsflyer:af-android-sdk:6.8.2'
41+
implementation 'androidx.test.ext:junit:1.1.5'
42+
implementation 'com.appsflyer:af-android-sdk:6.10.1'
2643
compileOnly 'com.android.installreferrer:installreferrer:2.1'
2744
compileOnly 'com.segment.analytics.android:analytics:4.+'
28-
testImplementation 'junit:junit:4.12'
29-
testImplementation 'org.mockito:mockito-core:1.10.19'
45+
testImplementation 'androidx.test:core:1.4.0'
46+
testImplementation 'junit:junit:4.13.2'
47+
testImplementation 'org.robolectric:robolectric:4.9.2'
48+
testImplementation 'com.android.installreferrer:installreferrer:2.1'
49+
testImplementation 'com.segment.analytics.android:analytics:4.+'
50+
testImplementation 'org.mockito:mockito-core:4.2.0'
3051
testImplementation 'com.segment.analytics.android:analytics-tests:4.+'
3152
}
3253

33-
apply from: file('publish.gradle')
54+
tasks.withType(Test) {
55+
testLogging {
56+
exceptionFormat "full"
57+
events "started", "skipped", "passed", "failed"
58+
showStandardStreams true
59+
}
60+
}
61+
62+
apply from:file("publish.gradle")

app/publish.gradle

Lines changed: 119 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,129 @@
1-
apply plugin: 'maven'
1+
apply plugin: 'maven-publish'
22
apply plugin: 'signing'
33

4-
afterEvaluate { project ->
5-
uploadArchives {
6-
repositories {
7-
mavenDeployer {
8-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
9-
pom.groupId = GROUP
10-
pom.artifactId = POM_ARTIFACT_ID
11-
pom.version = VERSION_NAME
12-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
13-
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
14-
}
15-
pom.project {
16-
name POM_NAME
17-
packaging POM_PACKAGING
18-
description POM_DESCRIPTION
19-
url POM_URL
20-
scm {
21-
url POM_SCM_URL
22-
connection POM_SCM_CONNECTION
23-
developerConnection POM_SCM_DEV_CONNECTION
24-
}
25-
licenses {
26-
license {
27-
name POM_LICENCE_NAME
28-
url POM_LICENCE_URL
29-
distribution POM_LICENCE_DIST
30-
}
31-
}
32-
developers {
33-
developer {
34-
id POM_DEVELOPER_ID
35-
name POM_DEVELOPER_NAME
4+
def isReleaseBuild() {
5+
return !VERSION_NAME.contains("SNAPSHOT")
6+
}
7+
8+
def getReleaseRepositoryUrl() {
9+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
10+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
11+
}
12+
13+
def getSnapshotRepositoryUrl() {
14+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
15+
: "https://oss.sonatype.org/content/repositories/snapshots/"
16+
}
17+
18+
task androidJavadocs(type: Javadoc) {
19+
exclude "**/*.orig" // exclude files created by source control
20+
source = android.sourceSets.main.java.srcDirs
21+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
22+
failOnError false
23+
}
24+
25+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
26+
archiveClassifier.set("javadoc")
27+
28+
from androidJavadocs.destinationDir
29+
}
30+
31+
task androidSourcesJar(type: Jar) {
32+
archiveClassifier.set("sources")
33+
34+
from android.sourceSets.main.java.source
35+
}
36+
37+
def logger(log) {
38+
println log
39+
}
40+
41+
def configurePom(pom) {
42+
logger("configurePom")
43+
pom.name = POM_NAME
44+
pom.packaging = POM_PACKAGING
45+
pom.description = POM_DESCRIPTION
46+
pom.url = POM_URL
47+
48+
pom.scm {
49+
url = POM_SCM_URL
50+
connection = POM_SCM_CONNECTION
51+
developerConnection = POM_SCM_DEV_CONNECTION
52+
}
53+
54+
pom.licenses {
55+
license {
56+
name = POM_LICENCE_NAME
57+
url = POM_LICENCE_URL
58+
distribution = POM_LICENCE_DIST
59+
}
60+
}
61+
62+
pom.developers {
63+
developer {
64+
id = POM_DEVELOPER_ID
65+
name = POM_DEVELOPER_NAME
66+
}
67+
}
68+
}
69+
70+
afterEvaluate {
71+
publishing {
72+
publications {
73+
release(MavenPublication) {
74+
logger("release")
75+
// The coordinates of the library, being set from variables that
76+
// we'll set up in a moment
77+
groupId GROUP
78+
artifactId POM_ARTIFACT_ID
79+
version VERSION_NAME
80+
81+
// Two artifacts, the `aar` and the sources
82+
// artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
83+
artifact bundleReleaseAar
84+
artifact androidSourcesJar
85+
artifact androidJavadocsJar
86+
87+
// Self-explanatory metadata for the most part
88+
pom {
89+
configurePom(pom)
90+
// A slight fix so that the generated POM will include any transitive dependencies
91+
// that the library builds upon
92+
withXml {
93+
def dependenciesNode = asNode().appendNode('dependencies')
94+
95+
project.configurations.implementation.allDependencies.each {
96+
def dependencyNode = dependenciesNode.appendNode('dependency')
97+
dependencyNode.appendNode('groupId', it.group)
98+
dependencyNode.appendNode('artifactId', it.name)
99+
dependencyNode.appendNode('version', it.version)
36100
}
37101
}
38102
}
39103
}
40104
}
41-
}
42-
signing {
43-
required { gradle.taskGraph.hasTask("uploadArchives") }
44-
sign configurations.archives
45-
}
46-
task androidJavadocs(type: Javadoc) {
47-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
48-
if (JavaVersion.current().isJava8Compatible()) {
49-
allprojects {
50-
tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') }
105+
repositories {
106+
maven {
107+
name = "sonatype"
108+
109+
// You only need this if you want to publish snapshots, otherwise just set the URL
110+
// to the release repo directly
111+
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
112+
113+
credentials(PasswordCredentials) {
114+
username = getRepositoryUsername()
115+
password = getRepositoryPassword()
116+
}
51117
}
52118
}
53119
}
54-
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
55-
archiveClassifier = 'javadoc'
56-
from androidJavadocs.destinationDir
57-
}
58-
task androidSourcesJar(type: Jar) {
59-
classifier = 'sources'
60-
from android.sourceSets.main.java.sourceFiles
61-
}
62-
artifacts { archives androidJavadocsJar }
63-
}
120+
}
121+
122+
signing {
123+
logger("signing")
124+
sign publishing.publications
125+
}
126+
127+
128+
publish.dependsOn build
129+
publishToMavenLocal.dependsOn build
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package com.segment.analytics.android.integration.appsflyer;
2-
3-
import android.app.Application;
4-
import android.test.ApplicationTestCase;
5-
6-
/**
7-
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8-
*/
9-
public class ApplicationTest extends ApplicationTestCase<Application> {
10-
public ApplicationTest() {
11-
super(Application.class);
12-
}
13-
}
1+
//package com.segment.analytics.android.integration.appsflyer;
2+
//
3+
//import android.app.Application;
4+
//import android.test.ApplicationTestCase;
5+
//
6+
///**
7+
// * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
// */
9+
//public class ApplicationTest extends ApplicationTestCase<Application> {
10+
// public ApplicationTest() {
11+
// super(Application.class);
12+
// }
13+
//}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest package="com.segment.analytics.android.integrations.appsflyer">
3-
4-
<application />
5-
3+
<application/>
64
</manifest>

app/src/main/java/com/segment/analytics/android/integrations/appsflyer/AppsflyerIntegration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public static void startAppsFlyer(@NonNull Context context){
8080
public static final Factory FACTORY = new Integration.Factory() {
8181
@Override
8282
public Integration<AppsFlyerLib> create(ValueMap settings, Analytics analytics) {
83+
if(settings == null || analytics == null){
84+
return null;
85+
}
8386
Logger logger = analytics.logger(APPSFLYER_KEY);
8487
AppsFlyerLib afLib = AppsFlyerLib.getInstance();
8588

0 commit comments

Comments
 (0)