bundletool build-bundle error: [BT:1.8.2] Error: Version code not found in manifest - android-build

I am trying to turn an apk into aab, decompile with apktool, and build with aapt2 and bundletool (all in command line, without gradle).
After decompile, aapt2 compile and link looks good, but when I execute build-bundle with bundletool, I got this error. What went wrong? And How can i fix it?
# 1. Decompile apk and copy res[folder] and Androidmanifest.xml into $HOME/apk2aa/temp_dir
apktool d input.apk
# 2. “Compile” all resources using aapt2
aapt2 compile --dir input/res -o "${APPROOT}/temp_dir/compiled_resources"
# 3. “Link” the resources into a temporary APK, generating the R.java file along the way and converting the resources into protobuf format:
aapt2 link --proto-format -o temporary.apk -I "${SDK}/platforms/android-29/android.jar" --manifest input/AndroidManifest.xml -R compiled_resources/*.flat --auto-add-overlay --java gen
I then generate a zip (base.zip) from a folder with the same structure as described here: https://developer.android.com/studio/build/building-cmdline#package_pre-compiled_code_and_resources
# 4. Use bundletool build-bundle command to create aab
java -jar "${APPROOT}/bundletool.jar" build-bundle --modules=base.zip --output=output.aab
Log:
[BT:1.8.2] Error: Version code not found in manifest.
com.android.tools.build.bundletool.model.exceptions.InvalidVersionCodeException: Version code not found in manifest.
at com.android.tools.build.bundletool.model.exceptions.InvalidVersionCodeException.createMissingVersionCodeException(InvalidVersionCodeException.java:29)
...
The AndroidManifest.xml produced by apktool is missing android:versionCode tag as it can be seen here:
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="30" android:compileSdkVersionCodename="11" package="com.hairlight.mediapipe.apps.hairsegmentationgpu" platformBuildVersionCode="30" platformBuildVersionName="11">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<application android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="#style/AppTheme">
<activity android:exported="true" android:name="com.hairlight.mediapipe.apps.basic.MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
The apktool.yml file has the versionCode
!!brut.androlib.meta.MetaInfo
apkFileName: input.apk
compressionType: false
doNotCompress:
- resources.arsc
- png
- assets/empty_asset_generated_by_bazel~
isFrameworkApk: false
packageInfo:
forcedPackageId: '127'
renameManifestPackage: null
sdkInfo:
minSdkVersion: '21'
targetSdkVersion: '30'
sharedLibrary: false
sparseResources: false
unknownFiles: {}
usesFramework:
ids:
- 1
tag: null
version: 2.6.0
versionInfo:
versionCode: '8'
versionName: 1.0.0
The original AndroidManifest.xml file has the tag as well.
So, apktool finds the versionCode and then strips it from the AndroidManifest.xml and puts it in a yml file. How do I ensure that apktool leaves the versionCode in AndroidManifest.xml?
Any help would be appreciated.
Versions I used are:
aapt2-7.2.0-alpha07-7984345-linux.jar, bundletool-all-1.8.2.jar, build-tools 29.0.2, platform version 29, javac 1.8.0_312, apktool_2.6.0.jar

I have found a solution to my own problem. I can provide -m flag to decompile code like this:
apktool d -m input.apk
This flag will ensure to match original file and avoid stripping versionCode and versionName from AndroidManifest.xml

Related

Play store console detects android.permission.READ_PHONE_STATE requirement for a Vanilla React Native app

I created a react native app using react-native init. Did not change a single line of code. (Note: react-native version is 0.55.4)
I generated a singed release APK by following steps given in the official docs.
I tried to upload this APK to Google Play console.
I got the following error:
Your APK or Android App Bundle is using permissions that require a privacy policy: (android.permission.READ_PHONE_STATE)
This is an unexpected behaviour right? Why will a vanilla app require this permission? How can I solve this issue?
Edit 1
My Android manifest is the default one created by react-native init.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.praveenavtestproject">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
Edit 2
My app doesn't need any permission to work. It just displays 3 lines of text from a historical literature. It is just for information purpose. In Play Store Console, under Store listing tab, at the bottom, there is a Privacy Policy section. It says If you wish to provide a privacy policy URL for this application, please enter it below. Also, please check out our User Data policy to avoid common violations.
I am not providing a privacy policy URL. My app is not supposed to be accessing any user data or phone state. Does React Native access it by default? Can that be the reason for this issue?
Edit 3
Looks like this issue is already being looked at by React Native team.

Why my rebuilded openfl/lime 2.9.1 for haxeflixel always ingores my own androidmanifest uses permissions?

I use haxeflixel that create lime build android applications.
I rebuild lime 2.9.1 from source that lime can make android target sdk version 26, as google said soon be minimum version for playstore. This is the original article .
As result i can make lime build android with android target sdk api version 26.
-Project.xml <android minimum-sdk-version="9" if="android" /> <android target-sdk-version="26" if="android" />
-AndroidManifest.xml <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="26"/>
But, now lime always ignores my own AndroidManifest.xml
-Project.xml <template path="assets/data/AndroidManifest.xml" rename="AndroidManifest.xml" if="android"/>
as result, my apk in time of installation show me "app no need special permissions". But my own AndroidManifest.xml have syntax
AndroidManifest.xml
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
If i switch lime version to "prebuilded lime 2.9.1" installed by default in haxeflixel , which can't make android target sdk version 26, but can only 19, then all work normal. In time of apk installing process i see the messages about require special permissions for app, and android app work as expected.
I test it on both windows / linux , the result is same. Prebuilded lime work done, but rebuilded lime ingnore all uses permissions, but use rebuilded lime i still can set portrait/landscape screen orientation inside my own AndroidManifest.xml.
How fix ingnoring android uses permissions from rebuilded lime side?
Have you tried putting the permissions into the Project.hxml? Something like:
<android permission="android.permission.WRITE_EXTERNAL_STORAGE" />
<android permission="android.permission.ACCESS_NETWORK_STATE"/>
<android permission="android.permission.INTERNET"/>
<android permission="android.permission.WAKE_LOCK"/>
<android permission="android.permission.VIBRATE"/>
<android permission="android.permission.READ_EXTERNAL_STORAGE"/>

productFlavors application Id

I'm trying to make two types of builds in Android Studio usung productFlavors.
I need to have unique applicationId for each buld type.
And here is an issue:
First of all I add this code to my gradle file
productFlavors {
base {
applicationId "ru.Public.lib"
}
city {
applicationId "ru.Public.lib.city"
}
Then when I'm trying to build app with city type, Android Studio shows an error:
"Error:Execution failed for task ':app:processBaseDebugGoogleServices'.
No matching client found for package name 'ru.Public.lib.debug'"
After this I decided that I need to change package name at my Manifest file.
I tryed to change package name in Manifest by three ways:
In project structure I created new Manifest app > src > city > AndroidManifest.xml. At this file I use package="ru.Public.lib.city"
I didn't create a new Manifest. Instead of it I used a placehilder for package name like this: package="${applicationId}"
I combined these two methods: "using placeholder at new Manifest in app > src > city >"
All shown ways gives me an error in the Manifest: Android Studio colored activity names by red and says unsolved class 'Activity Name'
Here is a part of my Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.Public.lib">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="ru.Public.lib.app.Application"
android:hardwareAccelerated="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:largeHeap="true"
android:resizeableActivity="false"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBarDefault">
<activity
android:name=".activities.ActivityMain"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity
android:name=".activities.ActivityEdition"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
.....................................................................etc.
</manifest>
So. It looks like I need to recreate all my acivities in new directories acording to every packege name I need. But it is too complicated way. I'm sure that Google solved this problem.
Do anybody have some ideas about this issue?
Thanks!
Here are some step to solve it.
Go to your firebase console
Select your previous project and Add another app
Register another applicationId (Register all of your applicationID one by one)
Then Download new google-services.json
And place new google-services.json in your project
Thats it

NoClassDefFoundError Google-Play-Services / Maps

Getting NoClassDefFoundError within project and in Google Maps for Android sample found in google-play-services folder.
I have tried so far:
Importing google-play-services_lib into workspace through wizard and making sure code is copied to directory
Manually copying google-play-services_lib into directory with sample, then importing into workspace
Copying jar into workspace
Google Play Services is installed on test devices (Nexus 5, Galaxy S4)
There is a green check next to the library under my project when going to properties > android
I can see the classes in source at compile time, compiles with no errors
Reinstalled the lib from the Android SDK Manager and made sure the key is correct in Google API console; also made sure v2 of maps was enabled for that key
Added proguard exceptions as per integration instructions
Any ideas?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.projectname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<permission
android:name="com.package.projectname.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.package.projectname.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.package.projectname.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.package.projectname.MapActivity"
android:label="#string/title_activity_map"
android:parentActivityName="com.package.projectname.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.package.projectname.MainActivity" />
</activity>
<uses-library
android:name="com.google.android.maps"
android:required="true" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value=“my_key_from_google_api_console” />
</application>
</manifest>
I don't think you need the line:
<uses-library
android:name="com.google.android.maps"
android:required="true" />
In fact, I think that's the name of the old maps library. Try removing it and see if that fixes your problem. Also, make sure your code is importing from com.google.android.gms.maps and com.google.android.gms.maps.model, the packages for Google Maps API V2.
UPDATE
Your build configuration isn't including the Google Play Services jar in your APK.
To fix this in IntelliJ: https://stackoverflow.com/a/17977734/1235702
To fix this in Eclipse, follow steps 3 and 4 here: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw (I didn't write this doc, but kudos to whoever did!)
Add the Google Play Services project into your Eclipse workspace.
Click File -> Import..., select Android -> Existing Android Code into Workspace
Browse to and select /extras/google/google_play_services/libproject/google-play-services_lib
To add the dependency to Google Play Services into your project
Project -> Properties -> Android -> Library, Add -> google-play-services_lib
(Sorry; the markdown won't let me set the numbers to 3 and 4 explicitly.)
Screenshot from OP for posterity:

CruiseControl.Net error: Unknown plugin for <msbuild>

I'm trying to get CruiseControl.Net working with MSBuild (this is my first exposure to CruiseControl.Net). I thought I'd done the configuration correctly, however I just get the following error message when starting up:
[cc]Jun-22 20:02:55 Main - error setting config file on controller
net.sourceforge.cruisecontrol.CruiseControlException: error configuring project MyProject
at *SNIP*
Caused by: net.sourceforge.cruisecontrol.CruiseControlException: Unknown plugin for: <msbuild>
at *SNIP*
[cc]Jun-22 20:02:55 Main - error configuring project MyProject
As far as I can work out, this would appear to indicate that I'm missing the MSBuild plugin, however all documentation that I can find indicates that the MSBuild plugin has been included with CruiseControl.Net since version 1.0
I'm using the latest binary release (v 2.8.3)
Here is my config xml:
<project name="MyProject">
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers></bootstrappers>
<modificationset quietperiod="10">
<filesystem folder="C:\snip\main"/>
</modificationset>
<schedule interval="60">
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\snip\main</workingDirectory>
<projectFile>MyProject.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
<targets>Build;Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</schedule>
<log />
<publishers />
</project>
Any advice on how I can troubleshoot this would be much appreciated.
Aggg - it appears that I have unwittingly downloaded CruiseControl, instead of CruiseControl.Net (and to make things even more confusing I was looking at CruiseControl.Net documentation)