📜 ⬆️ ⬇️

Replacing the manifest when building in Marmalade for Android

In connection with the question asked by Nonameface , I want to publish a small guide that may be useful for someone. To many, the question under consideration may seem elementary. I ask you not to judge me harshly, because this material is addressed to novice developers.

The essence of this problem is that when building for Android, the manifest includes all the rights that an application developed in Marmalade may need. At the same time, no checks are performed on whether these rights are actually used by the application. As a result, the user installing the application has legitimate questions: “Why does the application require the right to read and send SMS, if it obviously does not work with this functionality?”.

The user, quite reasonably, may find the application unsafe and refuse to install it. Let's see how to deal with this.

Obviously, we need to do the build by somehow replacing the AndroidManifest.xml file. First, we need to get the original AndroidManifest.xml, which is formed by the Maramalade toolkit. Although the apk-file is essentially a zip-archive and retrieving the required file from it is not difficult, the task is somewhat complicated by the fact that the file is not stored in text, but in binary form. Apktool will help us extract the manifest file in the text view.
')
We download apktool1.5.1.tar.bz2 and apktool-install-windows-r05-ibot.tar.bz2 (if using Windows) to our computer, and unpack it into some local directory. I also need Java installed on my computer (I have jdk1.6.0_23 installed). You can unpack the apk-file with the following command:

apktool.bat d arcanoid.apk ./arcanoid 

Then, we find in the created directory AndroidManifest.xml converted to a text form and open it:

AndroidManifest.xml
 <?xml version="1.0" encoding="utf-8"?> <manifest android:versionCode="1" android:versionName="0.0.1" android:installLocation="auto" package="com.mycompany.arcanoid" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="@string/app_name" android:icon="@drawable/icon"> <activity android:label="@string/app_name" android:name=".Main" android:launchMode="singleTask" android:configChanges="locale|keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <provider android:name="com.ideaworks3d.marmalade.VFSProvider" android:exported="false" android:multiprocess="true" android:authorities="zzzz06b5522b12c49d3c5503d40887ddf6fa.VFSProvider" /> </application> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.BATTERY_STATS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.SET_ORIENTATION" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> </manifest> 


Further, we can edit this file to our own taste, for example, by removing unused permissions. In order for subsequent assemblies to use the edited version of the manifest, the following section must be added to the mkb file:

arcanoid.mkb
 ... deployments { ["Default"] android-aliasname='company' android-icon='icons/ic_launcher.png' android-icon-hdpi='icons/ic_launcher.png' android-icon-ldpi='icons/ic_launcher1.png' android-icon-mdpi='icons/ic_launcher2.png' android-manifest='Manifest/AndroidManifest.xml' caption='arcanoid' name='arcanoid' } 


That's basically it. After the described replacement of the manifest, testing the assembly on an Android device is necessary. It is possible that some part of the functionality will stop working, or the application simply stops running.

Source: https://habr.com/ru/post/167323/


All Articles