我是 Android 开发新手,这是我第一次尝试。当尝试运行 android studio 创建的模板项目时,我看到以下错误。
Failed to finalize session : INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed parse during installPackageLI: Failed to read manifest from /data/app/vmdl2093545946.tmp/split_lib_slice_9_apk.apk: null
下面是AndroidManifest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.customtab">
<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>
这是 activity_main.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello Android !"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
想知道我在这里错过了什么。
当我尝试在 Android API 30 模拟器上运行针对 API30 的应用程序时,我也刚刚遇到了此错误。清理和重新构建没有帮助,将目标 API 降级回 29 对我来说不是一个选择,因为我需要测试针对 API 30 的应用程序。结果发现原因是 Android Studio 中启用了即时运行功能。
在这里找到了解决方案。
尝试从“设置”>“构建执行、部署”>“即时运行”关闭“即时运行”。 然后重建您的项目并运行它。