gpt4 book ai didi

android - Cordova 发布内置 APK 无法在 Android 上安装

转载 作者:行者123 更新时间:2023-12-03 16:50:48 25 4
gpt4 key购买 nike

命令“Cordova build android”生成一个名为 app-debug.apk 的 apk 文件,我可以将其安装在我的设备上(带有 Android v8.0 的三星 A3)

命令“Cordova build android --release”会生成一个名为 app-release-unsigned.apk 的 apk 文件,该文件不会安装在同一设备上(“未安装应用程序”)。

我还必须补充一点,我并不想在 Playstore 上发布该 apk。我也尝试签署 APK,但它不会改变结果。

这两个文件之间的本质区别应该是什么?导致发布版本失败的原因可能是什么?

这是位于 Cordova 项目文件夹中的 config.xml 的内容:

<?xml version='1.0' encoding='utf-8'?>
<widget id="eu.jrc.treechecker" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>TreeChecker</name>
<description>
A mobile application
</description>
<author email="*******" href="********">
Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<icon src="www/img/ic_canhemon.png" />
<platform name="android">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="24" />
<preference name="android-targetSdkVersion" value="28" />
</platform>
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="cordova-plugin-spinner-dialog" spec="^1.3.1" />
<plugin name="cordova-plugin-dbcopy" spec="^2.1.2" />
<plugin name="cordova-sqlite-storage" spec="^3.1.0" />
</widget>

这是platforms/android/app/src/main/AndroidManifest.xml的内容:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="eu.jrc.treechecker" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
</application>
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

编辑:这是我将用于 build.json 的内容:
{
"android": {
"debug": {
"keystore": "appname-mobileapps.keystore",
"storePassword": "***",
"alias": "appname-mobileapps",
"password" : "***",
"keystoreType": ""
},
"release": {
"keystore": "appname-mobileapps.keystore",
"storePassword": "***",
"alias": "appname-mobileapps",
"password" : "***",
"keystoreType": ""
}
}
}

最佳答案

调试构建和发布构建是两个不同的东西。第一个适用于开发人员,而第二个适用于您的用户。为了在 Cordova 中生成发布版本,您可以使用 Cordova CLI或使用 Android Studio .

Cordova CLI

为了使用 CLI 进行发布构建,您需要运行 cordova build --release以及一组参数。在没有配置的情况下运行命令不会成功构建。这些参数对于为 Play 商店签署您的应用程序是必要的。此外,这些配置可以在 cli 中提供,也可以通过 build.json 提供。配置文件。 Cordova 文档 Signing an App让您更深入地了解这一点。

安卓工作室

这种方式是一种相对简单的方式来进行发布构建。您需要做的就是将您的应用程序加载到 android studio,然后按照屏幕上的说明操作 Generate Signed apk获取发布版本。它将要求您创建一个 key 文件,这是 future 版本所必需的。

关于android - Cordova 发布内置 APK 无法在 Android 上安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57398685/

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