Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Source Context integration doesn't support most Android repositories #74435

Closed
zsperske opened this issue Jul 17, 2024 · 8 comments
Closed

Comments

@zsperske
Copy link

zsperske commented Jul 17, 2024

Problem Statement

The "known limitations" of the Source Context feature on Android mentions Package declaration and file tree must match for source lookup to work. Most Android repositories cannot meet this requirement. A basic Android project with only one Gradle module would have a file hierarchy that looks like this:

repoRoot/
    app/
         src/main/java
              com/company/app
                    MainActivity.kt
    build.gradle.kts

The package name of MainActivity.kt will be com.company.app. The limitations say that the file must live in the com/company/app directory relative to the project root when in fact it will live in app/src/main/java/com/company/app.

Package names only match file hierarchy relative to the java (or kotlin) directories within their respective Gradle module. Any amount of directories can exist above that point.

One "easy" fix would be to allow specifying a root directory to start looking from (app/src/main/java in this example), however this could easily break if the project is refactored and would also not support multi module projects which is most mature Android projects. Here's an example file hierarchy of a multi-module project:

repoRoot/
    build.gradle.kts
    app/
         build.gradle.kts
         src/main/java
              com/company/app
                    MainActivity.kt
     features/
         feature1/
              build.gradle.kts
              src/main/java
                  com/company/feature1
                      SomeClass.kt
    libraries/
         networking/
             build.gradle.kts
             src/main/java
                  com/company/networking
                      SomeOtherClass.kt

There are multiple Gradle modules, with varying numbers of layers of directories above them. Again the "easy" solution might be to allow specifying multiple source directories to search in but this would quickly become a maintenance nightmare. Real world Android projects have hundreds or even thousands of Gradle modules.

For a real example here is a Github project: https://github.com/vmadalin/android-modular-architecture

Solution Brainstorm

The settings.gradle file in a Gradle project could be used to find the path to each Gradle module in the project. Another option is looking for build.gradle and build.gradle.kts files as they appear in the root directory of a given Gradle module.

However, I wouldn't be surprised if there are lots of edge cases that wouldn't be covered by these.

Product Area

Issues - Source Maps

@getsantry
Copy link
Contributor

getsantry bot commented Jul 17, 2024

Assigning to @getsentry/support for routing ⏲️

@getsantry
Copy link
Contributor

getsantry bot commented Jul 17, 2024

Routing to @getsentry/product-owners-issues-source-maps for triage ⏲️

@getsantry getsantry bot moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3 Jul 17, 2024
@mrduncan
Copy link
Member

Really appreciate the detail here, thank you! For full transparency, we don't have any planned work in this area at the moment but we will review and follow up when that changes.

@kahest
Copy link
Member

kahest commented Jul 17, 2024

There is a related issue on the SAGP repo about supporting source context for multi-module setups: getsentry/sentry-android-gradle-plugin#685

@realkosty
Copy link
Contributor

@kahest @mrduncan Is there any workaround we can think of? I'm wondering if there's a way to add a simple script as a step before Sentry gradle plugin runs that copies all source code into the root directory, then cleans up after?

@getsantry
Copy link
Contributor

getsantry bot commented Jul 22, 2024

Routing to @getsentry/product-owners-processing for triage ⏲️

@getsantry
Copy link
Contributor

getsantry bot commented Jul 23, 2024

Routing to @getsentry/product-owners-processing for triage ⏲️

@markushi
Copy link
Member

As this is mainly a topic for our Sentry Android Gradle plugin, let's close this in favor of getsentry/sentry-android-gradle-plugin#685

@markushi markushi closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Jul 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Archived in project
Development

No branches or pull requests

8 participants