【问题标题】:Error parsing the package解析包时出错
【发布时间】:2016-07-11 14:22:53
【问题描述】:

这个错误一直出现在我的手机上,但之前没有出现,我看到了所有的堆栈溢出方法,但没有一个可以帮助我。

当我从 android studio 测试应用程序到我的手机时出现此错误。我也在其他手机上尝试过,但问题仍然存在。

这是我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.patel.pritesh.smstimer">

    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/sms_timer"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".Time_Picker"
            android:theme="@style/AppTheme.NoActionBar" />

        <receiver
            android:name=".MyReceiver"
            android:enabled="true"
            android:excludeFromRecents="true"
            android:exported="true"
            android:process="remote"
            android:taskAffinity="">
            <intent-filter>
                <action android:name="SEND" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".NotificationReciever"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="notification" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".deliveryReciever"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="notification_delivered" />
            </intent-filter>
        </receiver>

        <activity android:name=".sms_list">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".sms_review" />

        <service
            android:name=".alarmService"
            android:enabled="true"
            android:exported="true"></service>
    </application>

</manifest>

此错误出现在运行选项卡中:

Unexpected error while executing: am start -n "my.patel.pritesh.smstimer/my.patel.pritesh.smstimer.sms_list" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

启动活动时出错

【问题讨论】:

  • 错误是什么?发布您的位置
  • 这些在 logcat 中没有错误,只是表明在我的手机上解析包时出现问题

标签: android android-studio


【解决方案1】:

清单文件的主标签必须是清单。而不是 xml 标签,写如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.dummy"
    android:versionCode="100"
    android:versionName="1.0.0" >

<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/sms_timer"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

   ...
</application>

</manifest>

【讨论】:

  • 所以你的意思是我应该删除顶部的 xml 标签?
  • logcat 的具体错误是什么?在您的清单中,我没有看到清单标签。你有吗?
  • 我添加了整个清单文件,我无法理解清单选项卡。标签在那里
  • 我刚刚注意到有一个错误显示无法解析器 getDefaultProguardFile。我该如何解决这个问题。
  • 你在使用proguard吗?您是在构建您的 apk 的调试版本还是发布版本?在没有 proguard 的情况下尝试调试风格。
【解决方案2】:

当您使用 Android Studio 时,我相信您可能遇到this question 中提到的问题,并且正如答案中提到的here 中提到的,当您更改项目的构建版本时会发生此错误(例如降级或升级):

过去 8 年我一直在研究同样的问题 小时...从 2.0 回滚到 1.5.1 后您没有遇到任何问题吗?

我注意到,即使出现错误,运行应用程序也能正常运行 有时。

所以你必须确保你使用的新版本没有问题,然后你必须再次清理和重建你的项目,就像提到的here


或者你可以使用this answer的以下提示:

删除.idea文件夹和gradle文件夹,然后点击按钮同步 带有 gradle gradle 文件的项目,在这个过程完成后,你是 能够正常运行您的应用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 2014-12-18
    • 1970-01-01
    相关资源
    最近更新 更多