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

versionName reference instead of literal value fails #1234

Closed
padlar opened this issue Apr 27, 2016 · 2 comments
Closed

versionName reference instead of literal value fails #1234

padlar opened this issue Apr 27, 2016 · 2 comments
Milestone

Comments

@padlar
Copy link

padlar commented Apr 27, 2016

2.1.0/Mac/https://www.dropbox.com/s/0c6kwrqoutxtfh5/sampleapp.apk?dl=0

Steps to Reproduce

Run the app as it is to see the versionName.
Now, decode, build and run the app without making any changes. On running, you will see that the versionName is null. versionName is read using the following piece of code -

        PackageManager packageManager = getApplicationContext().getPackageManager();
        PackageInfo packInfo = packageManager.getPackageInfo(getApplicationContext().getPackageName(),0);
        text2.setText("VersionName = " + packInfo.versionName);
@iBotPeaches
Copy link
Owner

There is no versionCode in this application and versionName is a reference instead of a literal value.

Prior to the world of Gradle, you could use a reference, but with Gradle it will choke if you try and use a reference in the gradle configuration. This is such a small priority edge case. Please manually extract the literal value from the reference and use it as this is not on my radar for a fix any time soon.

The alternative is having Apktool detect a string reference in versionName and extract the literal value from that reference and then using that literal value in the parameter passed to aapt. In the past I've written functions that track down literal values from references, but these modified the original apk inserting said literal value which I don't like any more as that changes the original.

If anyone would like to submit a pull request. Please don't modify the original files, so just grab the value of the reference and pass that to AndroidLibResources. Accepting PRs to fix this.

@iBotPeaches iBotPeaches changed the title versionName field read programmatically is null after decode and building the app versionName reference instead of literal value fails Apr 28, 2016
iBotPeaches added a commit that referenced this issue Apr 29, 2016
@iBotPeaches iBotPeaches removed the Bug label Apr 29, 2016
@iBotPeaches iBotPeaches added this to the 2.1.1 milestone Apr 29, 2016
@iBotPeaches
Copy link
Owner

3e56693

Fixed. Thanks!

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

No branches or pull requests

2 participants