Step "apk-info" not returning package and version info

The “apk-info” step is returning empty for package, version_name and version_code fields.

=> APK Info: {:file_size_bytes=>12816076, :app_info=>{:app_name=>"XXX", :package_name=>"", :version_code=>"", :version_name=>"", :min_sdk_version=>"16", :icon_path=>"/Users/vagrant/git/mobile/android/app/build/outputs/apk/feature/release/icon.png", :icon_apk_path=>"res/mipmap-xxxhdpi-v4/ic_launcher.png"}}

I see someone had this same issue and it was solved, but I’m using the latest version of the step and it appears to still be happening.

Any ideas?

Hello @ignacioola,

We had indeed the same issue, and updating to a newer version of “Deploy to Bitrise” step temporarily fixed it, until the same problem re-appeared.

We have tried many things to fix it, none of them worked, so we finally simply dropped this step and use a custom script, with the tool aapt, allowing to extract the information we need. In your example, I think you might try:

package=$(aapt dump badging $apkPath | awk '/package/{gsub("name=|'"'"'","");  print $2}')
versionCode=$(aapt dump badging $apkPath | awk '/package/{gsub("versionCode=|'"'"'","");  print $3}')
versionName=$(aapt dump badging $apkPath | awk '/package/{gsub("versionName=|'"'"'","");  print $4}')
fileSize=$(stat -c%s $apkPath)

In the above, $apkPath refers to $BITRISE_APK_PATH.



Additionnal information :slight_smile:

  • you need to install aapt, using sudo apt -y install aapt

  • at the end you need to export the env variable once this is done, using something like:

    envman add --key ANDROID_APP_PACKAGE_NAME --value ${package}
    envman add --key ANDROID_APP_VERSION_CODE --value ${versionCode}
    envman add --key ANDROID_APP_VERSION_NAME --value ${versionName}
    envman add --key ANDROID_APK_FILE_SIZE --value ${fileSize}

This will use the same variable names as the original “APK Info” step, therefore the rest of your workflow can remained unchanged.


Hey @raphaelmina, great solution. Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.