Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change AndroidManifest.xml on Ionic v3.7.0

I'm using v3.7.0 and I want to change the AndroidManifest.xml when I build my app. Currently I have tried changing the my-project-path/config.xml file adding the the following lines:

Option a.

<widget>
    <preference name="android-manifest/application/activity/@android:windowSoftInputMode" value="adjustPan" />
</widget>

Option b.

<widget>
     <preference name="android-windowSoftInputMode" value="adjustPan" />
</widget>

Then I do:

$ ionic cordova build android

And I was expecting the following change on my-project-path/platform/android/AndroidManifest.xml:

<manifest>
    <application>
        <activity android:windowSoftInputMode="adjustPan">
        </activity>
    </application>
</manifest>

But I get the same result as without adding the preference settings:

<manifest>
    <application>
        <activity android:windowSoftInputMode="adjustResize">
        </activity>
    </application>
</manifest>

How can I apply the desired effect to the AndroidManifest.xml?

Thanks!

like image 527
JohnnyAce Avatar asked Sep 28 '17 23:09

JohnnyAce


People also ask

How do I change AndroidManifest xml?

Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element. Note: You must include the QUERY_ALL_PACKAGES permission if your app targets Android 11 (API Level 30) or higher.

Where is AndroidManifest xml in ionic?

xml ​ Android apps manage permissions, device features, and other settings in the AndroidManifest. xml file, which is located at android/app/src/main/AndroidManifest.

How do I open AndroidManifest xml?

Just open your APK and in treeview select "AndroidManifest. xml". It will be readable just like that.


1 Answers

I found how to do it. If your Cordova version is above 6.4.0 you can use the tag <edit-config> (http://cordova.apache.org/docs/en/7.x/plugin_ref/spec.html#edit-config) and I think that if you are using the latest version of Ionic probably you'll have a Cordova version above 6.4.0 (I have 7.1).

So the way to make the desired change that I wanted I had to set the my-project-path/config.xml file as follows:

<widget xmlns:android="http://schemas.android.com/apk/res/android">
  <platform name="android">
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
      <activity android:windowSoftInputMode="adjustPan" />
    </edit-config>
  </platform>
</widget>

Check that the widget has a new attribute.

With this change when I build the Android version the manifest my-project-path/platform/android/AndroidManifest.xml looks like this:

<manifest>
    <application>
        <activity android:windowSoftInputMode="adjustPan">
        </activity>
    </application>
</manifest>
like image 86
JohnnyAce Avatar answered Oct 17 '22 08:10

JohnnyAce