【发布时间】:2017-11-30 06:58:32
【问题描述】:
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pvijayalakshmi.previousversion">
<application
android:allowBackup="true"
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:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
成绩文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.example.pvijayalakshmi.previousversion"
minSdkVersion 15
targetSdkVersion 26
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'
}
我开发了一个应用程序。而且我已经在手机上安装了。
现在我需要在我的应用程序中添加一列。我在数据库中添加了一列。我对onUpgrade() 进行了更改。我已将数据库版本从 1 更改为 2。
我已经更改了gradle文件中的版本代码和版本名称。
我不想卸载应用程序并重新安装。我想自动升级应用。
现在我正在尝试在以前的应用程序也存在的手机中安装我的应用程序(在将列添加到数据库之后)。
我需要升级我以前存在的应用程序。但我在这里面临问题。当前应用程序不会覆盖以前的应用程序。两个应用程序包名称在这里相同。
我该如何克服这个问题。我需要程序化解决方案。
例如,我们有许多应用程序,例如 whatsapp。他们对应用程序和版本进行了更改。因此,我们直接更新到新版本,而无需卸载我们现有的 whatsapp。就像我正在努力做的那样。
任何帮助将不胜感激。
当我尝试安装应用程序时,它显示如下。
【问题讨论】:
-
只需卸载应用程序并再次运行。
-
你在小米品牌手机上使用?
-
我不想再次卸载并重新安装我的应用程序。我想覆盖以前的应用程序。@HemantParmar
-
不,moto g4 plus@Raja
-
你在 gradle 中的 applicationId 和 AndroidManifest 文件中的一样吗?
标签: android