gpt4 book ai didi

Android 12 APK 在安装时抛出无效包

转载 作者:行者123 更新时间:2023-12-04 23:56:52 27 4
gpt4 key购买 nike

我有一个 Azure 构建管道,它正在生成一个 APK,它可以在 Android 10 上正常安装(通过 AppCenter),但会弹出错误:

App not installed as package appears to be invalid


在安卓 12 上。 AndroidManifest.xml在解决方案中看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.myapplocal" android:installLocation="auto" android:versionCode="1" android:versionName="1.1">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:label="L MyApp" android:icon="@drawable/icon" android:largeHeap="true"></application>
</manifest>
当我通过 Android Studio 的 APK Analyze 检查 list 时选项,我看到了这个:
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="31" />

<uses-permission
android:name="android.permission.FLASHLIGHT" />

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

<uses-permission
android:name="android.permission.CAMERA" />

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:label="D MyApp"
android:icon="@ref/0x7f07015e"
android:name="crc646948444ac10504e5.MainApplication"
android:debuggable="true"
android:allowBackup="true"
android:largeHeap="true"
android:extractNativeLibs="true">

<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode" />

<activity
android:theme="@ref/0x7f0d0001"
android:label="MyApp"
android:icon="@ref/0x7f07015e"
android:name="crc646948444ac10504e5.MainActivity"
android:screenOrientation="1"
android:configChanges="0x680" />

<activity
android:theme="@ref/0x7f0d0000"
android:name="crc646948444ac10504e5.SplashActivity"
android:exported="true"
android:screenOrientation="1"
android:noHistory="true">

<intent-filter>

<action
android:name="android.intent.action.MAIN" />

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

<activity
android:label="Web Authenticator"
android:name="crc641e66d166111bdf3e.FormAuthenticatorActivity" />

<activity
android:label="Web Authenticator"
android:name="crc641e66d166111bdf3e.WebAuthenticatorActivity" />

<activity
android:label="Web Authenticator Native Browser"
android:name="crc641e66d166111bdf3e.WebAuthenticatorNativeBrowserActivity"
android:launchMode="1" />

<activity
android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity" />

<service
android:name="crc64a98abb514ffad9f1.KeepAliveService" />

<receiver
android:label="Essentials Connectivity Broadcast Receiver"
android:name="crc64a0e0a82d0db9a07d.ConnectivityBroadcastReceiver"
android:enabled="true"
android:exported="false" />

<receiver
android:name="crc643f46942d9dd1fff9.PowerSaveModeBroadcastReceiver"
android:enabled="true"
android:exported="false" />

<provider
android:name="mono.android.MultiDexLoader"
android:exported="false"
android:authorities="com.app.myapp.mono.android.MultiDexLoader.__mono_init__"
android:initOrder="1999999999" />

<provider
android:name="mono.MonoRuntimeProvider"
android:exported="false"
android:authorities="com.app.myapp.mono.MonoRuntimeProvider.__mono_init__"
android:initOrder="1999999998" />

<activity
android:theme="@ref/0x01030010"
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@ref/0x7f090008" />
</application>

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

我之前认为 Android 12 的问题在于 android:targetSdkVersion设置为 29但是在解决方案的 list 中更改它并更改项目文件的 TargetFrameworkVersion来自 v11.0v12.0也没有帮助。 (这是在 Visual Studio 中使用项目属性的 Application > Compile using Android version 值更新的。)
为了允许在最近的 Android 设备上安装,我可能会缺少什么? (恐怕我不熟悉 Xamarin 或 Android。)

最佳答案

如果你已经将编译版本提升到 31,那么你需要添加

android:exported="true"
致您的 Activity 、服务和接收者。见 here .
在你的情况下
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="31" />

<uses-permission
android:name="android.permission.FLASHLIGHT" />

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

<uses-permission
android:name="android.permission.CAMERA" />

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:label="D MyApp"
android:icon="@ref/0x7f07015e"
android:name="crc646948444ac10504e5.MainApplication"
android:debuggable="true"
android:allowBackup="true"
android:largeHeap="true"
android:extractNativeLibs="true">

<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode" />

<activity
android:theme="@ref/0x7f0d0001"
android:label="MyApp"
android:icon="@ref/0x7f07015e"
android:name="crc646948444ac10504e5.MainActivity"
android:screenOrientation="1"
android:configChanges="0x680"
android:exported="true"/>

<activity
android:theme="@ref/0x7f0d0000"
android:name="crc646948444ac10504e5.SplashActivity"
android:exported="true"
android:screenOrientation="1"
android:noHistory="true">

<intent-filter>

<action
android:name="android.intent.action.MAIN" />

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

<activity
android:label="Web Authenticator"
android:name="crc641e66d166111bdf3e.FormAuthenticatorActivity"
android:exported="true"/>

<activity
android:label="Web Authenticator"
android:name="crc641e66d166111bdf3e.WebAuthenticatorActivity"
android:exported="true"/>

<activity
android:label="Web Authenticator Native Browser"
android:name="crc641e66d166111bdf3e.WebAuthenticatorNativeBrowserActivity"
android:launchMode="1"
android:exported="true"/>

<activity
android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity"
android:exported="true"/>

<service
android:name="crc64a98abb514ffad9f1.KeepAliveService"
android:exported="true"/>
<receiver
android:label="Essentials Connectivity Broadcast Receiver"
android:name="crc64a0e0a82d0db9a07d.ConnectivityBroadcastReceiver"
android:enabled="true"
android:exported="false" />

<receiver
android:name="crc643f46942d9dd1fff9.PowerSaveModeBroadcastReceiver"
android:enabled="true"
android:exported="false" />

<provider
android:name="mono.android.MultiDexLoader"
android:exported="false"
android:authorities="com.app.myapp.mono.android.MultiDexLoader.__mono_init__"
android:initOrder="1999999999" />

<provider
android:name="mono.MonoRuntimeProvider"
android:exported="false"
android:authorities="com.app.myapp.mono.MonoRuntimeProvider.__mono_init__"
android:initOrder="1999999998" />

<activity
android:theme="@ref/0x01030010"
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@ref/0x7f090008" />
</application>

<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
请注意真正需要导出或不需要导出的内容并进行相应更改。
从 Android 11 开始,App Center 也可能需要强制应用签名者,请参阅 here , here ,以防万一,这里是 fragment

As of Android 11, it's mandatory to use the APK signer (if you use API level 30) as it will set some extra schemes "APK Signature Scheme v2 now required". App Center now (since Dec 17, 2020) signs Android applications using APK signer internally, instead of JAR signer which was used previously. As part of the feature to enable APK signer in App Center, Android signing task V3 was implemented, and requirements for new Signing task were to change how keystore file is saved - to store the keystore file in an AzDO secure file (Android signing build and release task - Azure Pipelines | Microsoft Docs).


WarningAny build configurations that had their keystore files uploaded prior to Dec 17, 2020 still use the APK Signature Scheme v2 signing method (jarsigner). To use the APK Signature Scheme v3 signing flow, users just have to re-upload their keystore files and save their branch configuration.

关于Android 12 APK 在安装时抛出无效包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71022310/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com