Skip to content

AndroidAOP is causing the application to fail during installation when running UI tests. #33

Closed
@nanthakumaran-s

Description

@nanthakumaran-s

I have completed the initial configuration for AndroidAOP in my multi-module project. I’ve set up the androidAopConfig in the app-level Gradle file and installed the necessary packages in the module-level Gradle file. However, I want to ensure this works during Android tests, but I’m encountering an issue where the app is not being installed on the emulator when running the tests.

NOTE: I haven’t tried installing the app in normal mode since my focus is solely on resolving the issue with AndroidTest.

app level build.gradle

plugins {
    ...
    id "android.aop"
}

androidAopConfig {
    enabled true
    include "***.automation", "***.automation.core"
    exclude "kotlin.jvm", "kotlin.internal", "kotlinx.coroutines.internal", "kotlinx.coroutines.android"
    verifyLeafExtends true
    cutInfoJson false
    increment true
}

Module level build.gradle

plugins {
    ...
    id "android.aop"
}
dependencies {
    ....
    implementation("io.github.FlyJingFish.AndroidAop:android-aop-core:2.1.5")
    implementation("io.github.FlyJingFish.AndroidAop:android-aop-annotation:2.1.5")
    implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.1.5")
}

Inside the module MatchAll.kt

@AndroidAopMatchClassMethod(
    targetClassName = "***.automation.*",
    methodName = ["*"]
)
class MatchAll: MatchClassMethod {
    override fun invoke(joinPoint: ProceedJoinPoint, methodName: String): Any? {
        Log.e("MatchAll", "---->${joinPoint.targetClass}--${joinPoint.targetMethod.name}--${joinPoint.targetMethod.parameterTypes.toList()}");
        return joinPoint.proceed()
    }
}

I have also tried using @CustomInterceptor, but that’s not working either. Additionally, I’m facing some configuration issues with ksp.

Error Log

Exception thrown during onBeforeAll invocation of plugin com.google.testing.platform.plugin.android.AndroidDevicePlugin.
Failed to install APK(s): ***.apk
INSTALL_FAILED_INVALID_APK: Scanning Failed.: Package ***/base.apk code is missing
com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK: Scanning Failed.: Package ***/base.apk code is missing
        at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1373)
        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1199)
        at com.android.tools.utp.plugins.deviceprovider.ddmlib.DdmlibAndroidDevice.installPackage(DdmlibAndroidDevice.kt)
        at com.android.tools.utp.plugins.deviceprovider.ddmlib.DdmlibAndroidDeviceController$executeAsync$deferred$1.invokeSuspend(DdmlibAndroidDeviceController.kt:180)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Library version number:
AndroidAOP: 2.1.5

------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------

Build time:   2022-11-25 13:35:10 UTC
Revision:     daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.16.1 (Microsoft 11.0.16.1+1-LTS)
OS:           Mac OS X 14.1 aarch64

Computer Type: Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions