如何解决错误修复后,APK软件包解析错误,尝试重新安装
最近3天内,我一直在处理APK软件包解析错误。最后,我只是制作了一个新项目,然后将旧项目中的文件复制到了新项目中。我希望这可以解决问题。但我想再次防止程序包解析错误..所以我需要一些建议。 这是我第一次遇到软件包解析错误的方法,也许有人可以看到我做错了什么。
我使用Android Studio开发了一个应用。 清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="packagename">
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.SEND_SMS" />
<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="packagename.MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="packagename.SMSUtils"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="SMS_SENT"/>
</intent-filter>
<intent-filter>
<action android:name="SMS_DELIVERED"/>
</intent-filter>
</receiver>
</application>
</manifest>
等级:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "packagename"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs',include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-auth:19.3.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
}
在包解析错误之前,我已经这样做了:
- 为了进行测试,我生成了一个签名的APK。
- 我将其放在我的网络服务器(app-release.apk)
- 下载(使用PHP,我将文件重命名为the_app.apk)
- 我将其安装在手机上。没问题。
- 在我的手机上对其进行测试。 (这部手机根本没有应用程序...干净的手机)
- 我发现了一个错误
这是错误:
mdw.setMId(sharedPreferences.getString(shared_id,""));
if(!mdw.getMId().equals("")) {
//Do Something
}
错误->当sharedPreferences不存在时,您会收到一条错误消息,原因是它想使用null对象作为字符串等于。 setMId和getMId是类中的函数。 所以简单的解决方法是:
String Mid = mdw.getMId();
if(Mid!=null) {
if (!Mid.equals("")) {
//do something
}
}
- 我已修复该错误
- 再次生成签名的APK(使用相同的密钥库和versionCode 2)。
- 将新文件(app-release.apk)放到我的网络服务器上。
- 从手机上卸载应用程序。
- 下载新文件。
然后开始解析包错误 显然是因为软件包已更改:)
我几乎可以在网上找到有关此错误的所有信息,以解决该错误。没有任何帮助。但是当我尝试使用Android Studio运行应用程序时,甚至什至开始出现错误。 因此,三天后,我决定只创建一个新项目,复制所有文件,并使用新的密钥库。 之所以可以这样做,是因为我尚未分发该应用程序。
现在有大问题了……
- 有人可以发现我做错了什么或任何建议吗?这样我可以再次防止程序包解析错误?
- 进行更新的最佳方法是什么。目前,用户将收到有关新版本的电子邮件。 (不使用Play商店)。该应用程序将不会在Google Playstore上分发
谢谢..
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。