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

Use java package name for loading BuildConfig #751

Merged
merged 1 commit into from
Jan 17, 2020
Merged

Use java package name for loading BuildConfig #751

merged 1 commit into from
Jan 17, 2020

Conversation

kristianheljas
Copy link
Contributor

Platforms affected

Android

Motivation and Context

Resolving BuildConfig using android package name (Context.getPackageName) will only work when java and android package names are the same.

Android package name is effectively its applicationId which does not have to match java package name.
A common practice is to use different android package names for different built variants/flavours, ie:

debug {
	applicationIdSuffix ".debug"
}

Now the applicationId (and android package name) might be something like com.example.debug, but BuildConfig will still resolve by com.example.BuildConfig instead of com.example.debug.ClassName

This pull request resolves issue #513.

Description

Now using java.lang.Class.getPackage() instead of android.content.Context.getPackageName()

Testing

Tested with and without applicationIdSuffix with single Android 9 device.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@janpio
Copy link
Member

janpio commented Jul 11, 2019

(Restart CI)

@janpio janpio reopened this Jul 11, 2019
@codecov-io
Copy link

codecov-io commented Jul 11, 2019

Codecov Report

Merging #751 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #751   +/-   ##
=======================================
  Coverage   66.57%   66.57%           
=======================================
  Files          18       18           
  Lines        1822     1822           
=======================================
  Hits         1213     1213           
  Misses        609      609

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cf3dcf...22c2e81. Read the comment docs.

@brody4hire
Copy link

Looks OK to me. It would be great if another member can review this. And I wonder if we can cover this in the test suite?

Copy link

@knight9999 knight9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Good.

@dpogue dpogue added this to the 9.0.0 milestone Aug 11, 2019
@erisu erisu merged commit 60e022f into apache:master Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants