Skip to content

Commit 26776e9

Browse files
committed
Fixed gradle and app issues
1 parent 47a8411 commit 26776e9

File tree

6 files changed

+147
-23
lines changed

6 files changed

+147
-23
lines changed

AdobeBranchExample/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.application'
22

33
android {
4+
namespace 'io.branch.adobe.demo'
45
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
56
defaultConfig {
67
applicationId "io.branch.adobe.demo"

AdobeBranchExample/src/main/java/io/branch/adobe/demo/DemoApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import io.branch.adobe.extension.AdobeBranchExtension;
1919
import io.branch.referral.Branch;
20+
import io.branch.referral.BranchLogger;
2021
import io.branch.referral.PrefHelper;
2122

2223
public class DemoApplication extends Application {
@@ -27,7 +28,7 @@ public class DemoApplication extends Application {
2728
public void onCreate() {
2829
super.onCreate();
2930

30-
Branch.enableLogging();
31+
Branch.enableLogging(BranchLogger.BranchLogLevel.VERBOSE);
3132

3233
Analytics.setVisitorIdentifier("custom_identifier_1234"); // to test custom visitor ID (key: "vid")
3334

AdobeBranchExample/src/main/java/io/branch/adobe/demo/SwagActivity.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import androidx.appcompat.app.AppCompatActivity;
1010
import androidx.appcompat.widget.Toolbar;
1111

12-
import com.adobe.marketing.mobile.ExtensionError;
13-
import com.adobe.marketing.mobile.ExtensionErrorCallback;
12+
import com.adobe.marketing.mobile.Extension;
13+
import com.adobe.marketing.mobile.ExtensionHelper;
1414
import com.adobe.marketing.mobile.MobileCore;
1515
import com.google.android.material.floatingactionbutton.FloatingActionButton;
1616
import com.google.android.material.snackbar.Snackbar;
@@ -28,7 +28,7 @@
2828
import io.branch.referral.util.LinkProperties;
2929
import io.branch.referral.util.ShareSheetStyle;
3030

31-
public class SwagActivity extends AppCompatActivity implements View.OnClickListener, ExtensionErrorCallback<ExtensionError> {
31+
public class SwagActivity extends AppCompatActivity implements View.OnClickListener {
3232
private static final String TAG = "Branch::SwagActivity";
3333

3434
public static final String SWAG_DATA = "swag";
@@ -75,21 +75,18 @@ protected void onResume() {
7575

7676
@Override
7777
public void onClick(View view) {
78-
switch (view.getId()) {
79-
case R.id.add_to_cart:
80-
doAddToCart(view);
81-
break;
82-
83-
case R.id.purchase:
84-
doPurchase(view);
85-
break;
78+
int id = view.getId();
79+
if (id == R.id.add_to_cart) {
80+
doAddToCart(view);
81+
} else if (id == R.id.purchase) {
82+
doPurchase(view);
8683
}
8784
}
88-
89-
@Override
90-
public void error(final ExtensionError extensionError) {
91-
Log.e(TAG, String.format("An error occurred while dispatching event %d %s", extensionError.getErrorCode(), extensionError.getErrorName()));
92-
}
85+
86+
//
87+
// public void error(final ExtensionError extensionError) {
88+
// Log.e(TAG, String.format("An error occurred while dispatching event %d %s", extensionError.getErrorCode(), extensionError.getErrorName()));
89+
// }
9390

9491

9592
private void init(String swagData) {

AdobeBranchExtension/build.gradle

Lines changed: 128 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
apply plugin: 'com.android.library'
1+
plugins {
2+
id 'com.android.library'
3+
id 'maven-publish'
4+
id 'signing'
5+
}
26

37
android {
8+
namespace 'io.branch.adobe.extension'
9+
10+
buildFeatures {
11+
buildConfig = true
12+
}
13+
414
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
515

616
defaultConfig {
@@ -14,11 +24,21 @@ android {
1424
}
1525

1626
buildTypes {
27+
debug {
28+
enableUnitTestCoverage = true
29+
enableAndroidTestCoverage = true
30+
buildConfigField "long", "VERSION_CODE", project.VERSION_CODE
31+
buildConfigField "String", "VERSION_NAME", "\"${project.VERSION_NAME}\""
32+
}
33+
1734
release {
1835
minifyEnabled false
1936
consumerProguardFile('proguard-rules.pro')
37+
buildConfigField "long", "VERSION_CODE", project.VERSION_CODE
38+
buildConfigField "String", "VERSION_NAME", "\"${project.VERSION_NAME}\""
2039
}
2140
}
41+
2242
compileOptions {
2343
sourceCompatibility JavaVersion.VERSION_1_8
2444
targetCompatibility JavaVersion.VERSION_1_8
@@ -53,4 +73,110 @@ dependencies {
5373
androidTestImplementation project(path: ':AdobeBranchExtension')
5474
}
5575

56-
apply from: 'https://raw.githubusercontent.com/BranchMetrics/GradleToMavenOptionalDependencies/master/gradle-maven-push.gradle'
76+
def isReleaseBuild() {
77+
return !VERSION_NAME.contains("SNAPSHOT")
78+
}
79+
80+
def getReleaseRepositoryUrl() {
81+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
82+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
83+
}
84+
85+
def getSnapshotRepositoryUrl() {
86+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
87+
: "https://oss.sonatype.org/content/repositories/snapshots/"
88+
}
89+
90+
def getRepositoryUsername() {
91+
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
92+
}
93+
94+
def getRepositoryPassword() {
95+
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
96+
}
97+
98+
publishing {
99+
publications {
100+
mavenJava(MavenPublication) {
101+
from components.findByName('release')
102+
groupId = GROUP
103+
artifactId = POM_ARTIFACT_ID
104+
version = VERSION_NAME
105+
106+
// // Attach sources and Javadocs
107+
// artifact androidSourcesJar
108+
// artifact androidJavadocsJar
109+
110+
// Configure POM
111+
pom {
112+
name.set(POM_NAME)
113+
description.set(POM_DESCRIPTION)
114+
url.set(POM_URL)
115+
packaging = POM_PACKAGING
116+
117+
scm {
118+
url.set(POM_SCM_URL)
119+
connection.set(POM_SCM_CONNECTION)
120+
developerConnection.set(POM_SCM_DEV_CONNECTION)
121+
}
122+
123+
licenses {
124+
license {
125+
name.set(POM_LICENCE_NAME)
126+
url.set(POM_LICENCE_URL)
127+
distribution.set(POM_LICENCE_DIST)
128+
}
129+
}
130+
131+
developers {
132+
developer {
133+
id.set(POM_DEVELOPER_ID)
134+
name.set(POM_DEVELOPER_NAME)
135+
}
136+
}
137+
138+
// Optional dependencies
139+
withXml {
140+
asNode().dependencies.dependency.findAll {
141+
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
142+
}.each {
143+
if (it.optional)
144+
it.optional.value = 'true'
145+
else
146+
it.appendNode('optional', 'true')
147+
}
148+
}
149+
}
150+
}
151+
}
152+
153+
repositories {
154+
maven {
155+
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
156+
credentials {
157+
username = getRepositoryUsername()
158+
password = getRepositoryPassword()
159+
}
160+
}
161+
}
162+
}
163+
164+
signing {
165+
useGpgCmd()
166+
sign publishing.publications.mavenJava
167+
}
168+
169+
task androidSourcesJar(type: Jar) {
170+
archiveClassifier.set("sources")
171+
from android.sourceSets.main.java.srcDirs
172+
}
173+
174+
task androidJavadocs(type: Javadoc) {
175+
source = android.sourceSets.main.java.srcDirs
176+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
177+
}
178+
179+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
180+
archiveClassifier.set("javadoc")
181+
from androidJavadocs.destinationDir
182+
}

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
54
repositories {
65
google()
76
mavenCentral()
@@ -10,7 +9,7 @@ buildscript {
109
}
1110
}
1211
dependencies {
13-
classpath "com.android.tools.build:gradle:8.7.1"
12+
classpath "com.android.tools.build:gradle:8.3.2"
1413

1514
// NOTE: Do not place your application dependencies here; they belong
1615
// in the individual module build.gradle files

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ BUILD_TOOLS_VERSION=30.0.2
3535
SUPPORT_LIB_VERSION=26.0.0
3636

3737
ANDROID_BUILD_TARGET_SDK_MINIMUM=21
38-
ANDROID_BUILD_TARGET_SDK_VERSION=32
38+
ANDROID_BUILD_TARGET_SDK_VERSION=34
3939
ANDROID_BUILD_TOOLS_VERSION=30.0.2
40-
ANDROID_BUILD_SDK_VERSION=32
40+
ANDROID_BUILD_SDK_VERSION=34
4141

4242
android.useAndroidX=true
4343
android.enableJetifier=true

0 commit comments

Comments
 (0)