Skip to content

PMD error on Android projects using Play Services or LeakCanary #37

Closed
@barriosnahuel

Description

@barriosnahuel

Hi!

I'm having two issues after upgrading to SCA v3.0.0.

First one is related to PMD, second one to Spotbugs.

Context

I was using v2.6.12 fine in the given context:

  • PMD enabled
  • Gradle v5.6.4
  • Android project
    • 'com.android.tools.build:gradle:3.6.2'
    • App module, 1 dynamic feature module, many library modules (all in the same repository)

Note: SCA v2.6.12 comes with PMD v6.20.0

Error

PMD runs ok in all modules but on the dynamic feature module, I'm getting the following result:

* What went wrong:
Execution failed for task ':my_anroid_dynamic_feature_module:processDebugAndroidTestResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:34:13-36:66: AAPT: error: resource xml/leak_canary_file_paths (aka com.github.myawesomeproject.awesomefeature.test:xml/leak_canary_file_paths) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:39:9-44:66: AAPT: error: resource mipmap/leak_canary_icon (aka com.github.myawesomeproject.awesomefeature.test:mipmap/leak_canary_icon) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:39:9-44:66: AAPT: error: resource string/leak_canary_display_activity_label (aka com.github.myawesomeproject.awesomefeature.test:string/leak_canary_display_activity_label) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:39:9-44:66: AAPT: error: resource style/leak_canary_LeakCanary.Base (aka com.github.myawesomeproject.awesomefeature.test:style/leak_canary_LeakCanary.Base) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:46:9-62:26: AAPT: error: resource drawable/leak_canary_tv_icon (aka com.github.myawesomeproject.awesomefeature.test:drawable/leak_canary_tv_icon) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:46:9-62:26: AAPT: error: resource bool/leak_canary_add_launcher_icon (aka com.github.myawesomeproject.awesomefeature.test:bool/leak_canary_add_launcher_icon) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:46:9-62:26: AAPT: error: resource mipmap/leak_canary_icon (aka com.github.myawesomeproject.awesomefeature.test:mipmap/leak_canary_icon) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:46:9-62:26: AAPT: error: resource string/leak_canary_display_activity_label (aka com.github.myawesomeproject.awesomefeature.test:string/leak_canary_display_activity_label) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:46:9-62:26: AAPT: error: resource style/leak_canary_LeakCanary.Base (aka com.github.myawesomeproject.awesomefeature.test:style/leak_canary_LeakCanary.Base) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:64:9-70:68: AAPT: error: resource mipmap/leak_canary_icon (aka com.github.myawesomeproject.awesomefeature.test:mipmap/leak_canary_icon) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:64:9-70:68: AAPT: error: resource string/leak_canary_storage_permission_activity_label (aka com.github.myawesomeproject.awesomefeature.test:string/leak_canary_storage_permission_activity_label) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/12544b80cee21462a629a686340edfa2/jetified-leakcanary-android-core-2.2/AndroidManifest.xml:64:9-70:68: AAPT: error: resource style/leak_canary_Theme.Transparent (aka com.github.myawesomeproject.awesomefeature.test:style/leak_canary_Theme.Transparent) not found.
         
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/1242a38a4d8d07b0c228c34712765379/jetified-play-services-basement-17.0.0/AndroidManifest.xml:23:9-25:69: AAPT: error: resource integer/google_play_services_version (aka com.github.myawesomeproject.awesomefeature.test:integer/google_play_services_version) not found.
         

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s
82 actionable tasks: 14 executed, 68 up-to-date

What I've tried

  • Bump 'com.android.tools.build:gradle:3.6.2' to v3.6.3 ==> same error
  • Bump Gradle to v6.3 ==> same error
  • Build a local version of SCA v3.0.0 downgrading to PMD v6.20.0 ==> same error
  • Remove dependency LeakCanary and its usages ==> same error (only for Play Services)
  • Clone project again ==> same error
  • Downgrade Gradle to v5.2.1 (with 'com.android.tools.build:gradle:3.4.1') ==> It works! 🤔

Why I tried downgrading to v5.2.1?
After upgrading to SCA v3.0.0, when running:

./gradlew spotbugs

I'm getting the following error:

No classes configured for SpotBugs analysis.

which is extremely similar to spotbugs/spotbugs-gradle-plugin#23.

But in this new context with Gradle v5.2.1 when running spotbugs I fall into spotbugs/spotbugs-gradle-plugin#90.

Since all was working ok before upgrading and even after upgrading but using the previous version of PMD, I think it's a bug on SCA itself (perhaps on the workaround I assume you're doing to make Spotbugs work with Android projects? Should I file a new issue for this Spotbugs behaviour?

I can share a branch to try on..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions