最近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'
}
在包解析错误之前,我已经这样做了:
这是错误:
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
}
}
然后开始解析包错误 显然是因为软件包已更改:)
我几乎可以在网上找到有关此错误的所有信息,以解决该错误。没有任何帮助。但是当我尝试使用Android Studio运行应用程序时,甚至什至开始出现错误。 因此,三天后,我决定只创建一个新项目,复制所有文件,并使用新的密钥库。 之所以可以这样做,是因为我尚未分发该应用程序。
现在有大问题了……
谢谢..