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

Comments

Projects
None yet
2 participants
@padlar

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 iBotPeaches added the Bug label Apr 28, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Apr 28, 2016

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.

Owner

iBotPeaches commented Apr 28, 2016

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 from versionName field read programmatically is null after decode and building the app to 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

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Apr 29, 2016

Owner

3e56693

Fixed. Thanks!

Owner

iBotPeaches commented Apr 29, 2016

3e56693

Fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment