Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

build: Upgrade AGP to version 8.0.2 #1795

Merged
merged 5 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/androidTestSuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
java-version: '17'

# Cache and restore the Gradle dependencies on multiple runs
- name: Gradle cache
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Run tests
run: |
chmod +x gradlew
./gradlew jacocoTestProdDebugUnitTestReport
./gradlew jacocoProdDebugUnitTestReport
./gradlew copyUnitTestBuildArtifacts

# Uploads the folder or file in path to GitHub
Expand All @@ -50,7 +50,7 @@ jobs:
uses: codecov/codecov-action@v2
with:
directory: artifacts
files: jacocoTestProdDebugUnitTestReport.xml
files: jacocoProdDebugUnitTestReport.xml
fail_ci_if_error: false
verbose: true

Expand All @@ -73,7 +73,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
java-version: '17'

# Install Python 2.7 to support Pillow library for screenshot testing
# Ref: https://github.com/facebook/screenshot-tests-for-android#requirements
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ quality:
@./gradlew assembleDebug

test:
@./gradlew jacocoTestProdDebugUnitTestReport
@./gradlew jacocoProdDebugUnitTestReport

validate: quality test

Expand Down
5 changes: 0 additions & 5 deletions OpenEdXMobile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<?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="org.edx.mobile"
android:installLocation="auto">

<!-- Required by app for server communication and video download -->
<!-- Required by Segment -->
<!-- Required by NewRelic -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- Required by NewRelic -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Required by app for preventing screen lock while playing a video -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

Expand Down
88 changes: 37 additions & 51 deletions OpenEdXMobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,28 @@ buildscript {

dependencies {
classpath 'org.yaml:snakeyaml:1.29'
//Included for NewRelic
classpath "com.newrelic.agent.android:agent-gradle-plugin:$newrelic_version"
//Screenshot testing library
classpath 'com.facebook.testing.screenshot:plugin:0.14.0'
classpath "com.google.gms:google-services:$gms_google_services"
// Jacoco-android Wrapper : https://github.com/arturdm/jacoco-android-gradle-plugin
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
}
}

apply plugin: 'edxapp'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' //To enable data binding with kotlin
apply plugin: 'com.dicedmelon.gradle.jacoco-android'
apply plugin: 'jacoco'
edx {
platform = ANDROID
}

apply plugin: 'newrelic'
apply plugin: 'com.facebook.testing.screenshot'
apply from: file('gradle_scripts/AndroidHelper.gradle')
apply plugin: 'dagger.hilt.android.plugin'
jacoco {
toolVersion = "0.8.8"
}
// Inspiration https://medium.com/@android2ee/playing-with-gradle-3-and-some-few-code-coverage-on-android-with-jacoco-47df7c9328ae
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
// ref: https://stackoverflow.com/a/68139455
jacoco.excludes = ['jdk.internal.*']
}

/**
* Computes a semantic version string, e.g. "1.0" or "2.5.7" by parsing git branches or tags.
* Branch name takes priority, otherwise the last annotated tag name will be used.
Expand Down Expand Up @@ -210,9 +200,6 @@ dependencies {
implementation "com.android.installreferrer:installreferrer:2.2"
implementation "androidx.browser:browser:1.3.0"

//New Relic Integration
implementation "com.newrelic.agent.android:android-agent:$newrelic_version"

// ViewPager2
implementation 'androidx.viewpager2:viewpager2:1.0.0'

Expand All @@ -228,8 +215,8 @@ dependencies {
testImplementation 'androidx.test:core-ktx:1.2.0'
testImplementation 'androidx.arch.core:core-testing:2.1.0'
// To mock static classes
testImplementation 'org.mockito:mockito-inline:3.4.0'
testImplementation ("org.mockito:mockito-core:2.19.0"){
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation ("org.mockito:mockito-core:5.3.1"){
exclude group: 'org.hamcrest'
}
testImplementation "org.robolectric:robolectric:4.7.3"
Expand Down Expand Up @@ -265,7 +252,7 @@ dependencies {
androidTestImplementation ('org.mockito:mockito-core:2.8.9'){
exclude group: 'org.hamcrest'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KOTLIN_VERSION}"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${KOTLIN_VERSION}"
implementation "com.android.billingclient:billing-ktx:$kotlin_version_billing"

// dependency on Shimmer for Android
Expand Down Expand Up @@ -329,12 +316,13 @@ if (isMicrosoftEnabled) {
}

android {
namespace APPLICATION_ID
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION

buildFeatures {
viewBinding true
dataBinding true
buildConfig true
}

flavorDimensions "default"
Expand Down Expand Up @@ -419,19 +407,6 @@ android {
sdCardEnabled : config.get('DOWNLOAD_TO_SD_CARD_ENABLED') ?: true]

testOptions.unitTests.includeAndroidResources = true
// Exclude auto generated files from the code coverage report
jacocoAndroidUnitTestReport {
excludes += ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*',
'android/databinding/**',
'com/android/databinding/**',
'**/androidx/databinding/**',
'**/AnnotationDatabaseImpl.class' // Generated by RoboBlender
]
}
}
sourceSets {
main {
Expand Down Expand Up @@ -470,14 +445,6 @@ android {
}
}

lintOptions {
abortOnError true
showAll true
warning 'TypographyQuotes', 'InvalidPackage'
error 'StopShip', 'ContentDescription'
warning 'MissingTranslation'
warning 'ImpliedQuantity'
}

productFlavors {
prod {
Expand Down Expand Up @@ -519,25 +486,21 @@ android {
}
}
}

packagingOptions {
exclude 'LICENSE.txt'
exclude 'APK LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
resources {
excludes += ['LICENSE.txt', 'APK LICENSE.txt', 'META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt']
}
}

testOptions {
unitTests.all {
maxHeapSize '1g'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
Expand All @@ -547,7 +510,13 @@ android {
* Ref: https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#important-2
*/
freeCompilerArgs = ['-Xjvm-default=all']
jvmTarget = "11"
jvmTarget = "17"
}
lint {
abortOnError true
error 'StopShip', 'ContentDescription'
showAll true
warning 'TypographyQuotes', 'InvalidPackage', 'MissingTranslation', 'ImpliedQuantity'
}
}

Expand Down Expand Up @@ -599,3 +568,20 @@ android.applicationVariants.all { variant ->
}
}
}

task jacocoProdDebugUnitTestReport(type: JacocoReport, dependsOn: ['testProdDebugUnitTest']) {
reports {
xml.required = true
html.required = true
}

def mainSrc = "${project.projectDir}/src/main/java"
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/prodDebug")

sourceDirectories.setFrom files([mainSrc])
classDirectories.setFrom files([debugTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
"jacoco/testProdDebugUnitTest.exec",
"outputs/unit_test_code_coverage/prodDebugUnitTest/testProdDebugUnitTest.exec"
])
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class LoginTask(
var loginAPI = EntryPointAccessors
.fromApplication(context, ProviderEntryPoint::class.java).getLoginAPI()

@Deprecated("Deprecated in Java")
override fun doInBackground(vararg voids: Void): AuthResponse? {
try {
return loginAPI.logInUsingEmail(username, password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.cast.framework.CastButtonFactory
import com.google.android.gms.cast.framework.CastStateListener
import org.edx.mobile.R
import org.edx.mobile.event.NewRelicEvent
import org.edx.mobile.googlecast.GoogleCastDelegate
import org.edx.mobile.logger.Logger
import org.greenrobot.eventbus.EventBus

abstract class BaseAppActivity : AppCompatActivity(), CastStateListener {

Expand All @@ -24,7 +22,6 @@ abstract class BaseAppActivity : AppCompatActivity(), CastStateListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EventBus.getDefault().post(NewRelicEvent(javaClass.simpleName))
googleCastDelegate = GoogleCastDelegate.getInstance(
MainApplication.getEnvironment(this)
.analyticsRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import com.google.android.material.snackbar.Snackbar;

import org.edx.mobile.R;
import org.edx.mobile.event.NewRelicEvent;
import org.edx.mobile.http.notifications.SnackbarErrorNotification;
import org.edx.mobile.util.PermissionsUtil;
import org.greenrobot.eventbus.EventBus;

public class BaseFragment extends Fragment {
public interface PermissionListener {
Expand All @@ -29,7 +27,6 @@ public interface PermissionListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().post(new NewRelicEvent(getClass().getSimpleName()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.edx.mobile.base;


import android.content.Context;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
Expand All @@ -14,14 +13,12 @@
import com.braze.configuration.BrazeConfig;
import com.google.firebase.FirebaseApp;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.newrelic.agent.android.NewRelic;

import org.edx.mobile.BuildConfig;
import org.edx.mobile.authentication.LoginAPI;
import org.edx.mobile.core.EdxDefaultModule;
import org.edx.mobile.core.IEdxEnvironment;
import org.edx.mobile.event.AppUpdatedEvent;
import org.edx.mobile.event.NewRelicEvent;
import org.edx.mobile.http.HttpStatus;
import org.edx.mobile.logger.Logger;
import org.edx.mobile.model.api.UnacknowledgedNoticeResponse;
Expand Down Expand Up @@ -89,18 +86,6 @@ private void init() {

EventBus.getDefault().register(new CrashlyticsCrashReportObserver());

if (config.getNewRelicConfig().isEnabled()) {
EventBus.getDefault().register(new NewRelicObserver());
}

// initialize NewRelic with crash reporting disabled
if (config.getNewRelicConfig().isEnabled()) {
//Crash reporting for new relic has been disabled
NewRelic.withApplicationToken(config.getNewRelicConfig().getNewRelicKey())
.withCrashReportingEnabled(false)
.start(this);
}

// Add Segment as an analytics provider if enabled in the config
if (config.getSegmentConfig().isEnabled()) {
analyticsRegistry.addAnalyticsProvider(segmentAnalytics);
Expand Down Expand Up @@ -213,14 +198,6 @@ public void onEventMainThread(Logger.CrashReportEvent e) {
}
}

public static class NewRelicObserver {
@Subscribe
@SuppressWarnings("unused")
public void onEventMainThread(NewRelicEvent e) {
NewRelic.setInteractionName("Display " + e.getScreenName());
}
}

@NonNull
public static IEdxEnvironment getEnvironment(@NonNull Context context) {
return EntryPointAccessors
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class EnqueueDownloadTask(
private var transcriptManager = EntryPointAccessors
.fromApplication(context, ProviderEntryPoint::class.java).getTranscriptManager()

@Deprecated("Deprecated in Java")
override fun doInBackground(vararg params: Void?): Long {
var count = 0
for (downloadEntry in downloadList) {
Expand Down
Loading