Home > Web Front-end > uni-app > body text

Detailed explanation of the problem of uniapp Android not covering the installation (solution)

PHPz
Release: 2023-04-06 14:53:20
Original
3472 people have browsed it

With the rapid development of mobile device application development, more and more developers and users are beginning to use the uniapp platform to develop and run their own applications. However, during actual use, some users found that if they want to update uniapp Android, the program will be installed repeatedly, but the original application cannot be overwritten. In this case, what should be done to achieve successful installation and coverage? This article will elaborate on the problem of uniapp Android not covering the installation and its solution.

1. What is uniapp

First of all, we need to clarify what uniapp is.

uniapp is an open source framework based on Vue.js. It can generate applications for multiple platforms through one compilation, and supports multiple application scenarios such as App Store, Google Play, mini programs, and H5. Through component development based on Vue syntax, uniapp can greatly improve development efficiency and code reusability. At the same time, it can also easily realize cross-platform and one-time development of multiple terminals.

2. The problem of uniapp Android not covering the installation

However, for some developers and users, the uniapp Android program faces repeated installation when updating and cannot cover the original application. .

The specific performance is that when downloading and installing the program package, uniapp will install the program in a new folder to coexist with the original program instead of replacing the original program, causing the user to manually delete it Original installation package to use the updated application.

It may seem like this problem is very troubling, but in fact it only takes one simple step to achieve installation coverage.

3. Solution to uniapp Android not covering the installation

1. Modify the AndroidManifest.xml file

First, enter the platforms/android/ project package in the root directory of the uniapp project In the /src/main/ directory, find the file AndroidManifest.xml and open it.

In the AndroidManifest.xml file, find the following code:

<application
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
Copy after login

Add a new attribute in the code: android:installLocation="auto", the modified code is as follows:

<application
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:installLocation="auto"
    android:theme="@style/AppTheme">
Copy after login

This step allows the Android system to automatically determine the installation location of the application, usually choosing to overwrite the previous installation package.

2. Set the version number

In AndroidManifest.xml, find the following code:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your.package.name"
    android:versionCode="1"
    android:versionName="1.0">
Copy after login

Modify the versionCode (version number) in the code, every time you update the versionCode Higher than the previous version, the modified versionCode can be 2, that is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your.package.name"
    android:versionCode="2"
    android:versionName="1.0">
Copy after login

3. Recompile and package

Open the command line, enter the uniapp project root directory, and execute the following command. Recompile and package:

npm run dev:app-plus

npm run build:app-plus

At this time, when downloading and installing the updated version of the application, Android will choose to overwrite the original application instead of installing it in a new folder.

4. Summary

Through the above steps, we successfully solved the problem of uniapp Android not covering the installation.

While repeated installations are a minor issue, they can be a big problem for users. Therefore, we need to provide corresponding solutions to help users better use our applications.

As an emerging cross-platform application development framework, uniapp will become one of the mainstreams of mobile Internet application development in the future. I hope this article can provide some help to uniapp developers and users.

The above is the detailed content of Detailed explanation of the problem of uniapp Android not covering the installation (solution). For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template