android - 该软件包似乎已损坏(但通过电报安装)
问题描述
在从文件管理器在 android 设备上安装我的 apk 文件时,我遇到了一个非常奇怪的问题,一些信息是:
- 我在 android studio v.3.4.2 中构建签名的 apk
- 由 jarsigner 测试验证,没有错误
- 使用 V1 和 V2 签名构建(没有区别)
- 测试调试模式 apk 并同时发布
- 目标 sdk 为 25 (android 7.1.1)
- 我检查了“未知的 apk 安装”并且已启用
- 我检查了文件管理器安装 apk 的权限并且已启用
我使用 USB 电缆将签名的 apk 复制到设备内部存储中的下载文件夹中。奇怪的问题是当我尝试从下载文件夹安装 apk 时,此消息显示:
包裹似乎已损坏
所以我在电报上发送apk文件并尝试从中安装它,一切正常。
我认为某处缺少安装apk的权限。有人有建议吗?
谢谢
这是我的 manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx">
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_one"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_one"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</manifest>
这是我的 Gradle.app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 25
targetSdkVersion 28
versionCode 2
versionName "2"
maxSdkVersion 28
multiDexEnabled true
}
signingConfigs {
release {
storeFile file("path to key.jks")
storePassword "some password"
keyAlias "key0"
keyPassword "some password"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "nameapk"
def SEP = "_"
def version = variant.versionName
def date = new Date();
def formattedDate = date.format('ddMMyy_HHmm')
def newApkName = project+".apk"
outputFileName = new File(newApkName)
}
}
}
debug {
minifyEnabled false
signingConfig signingConfigs.release
}
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.core:core-ktx:1.2.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0@aar'
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation "com.google.code.ksoap2-android:ksoap2-android-assembly:${var}"
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
解决方案
推荐阅读
- excel - 动态重新定义 Excel 范围
- docker-compose - OCI 运行时执行失败:执行失败:container_linux.go:348:启动容器进程导致“没有这样的文件或目录”:未知
- linux - 100% 内核 CPU 终止与服务器的连接
- jquery - ajax 从 Spring Boot 获取 html 页面
- node.js - Alexa 音频播放器指令
- reactjs - 如何在反应中隐藏/显示特定组件
- assembly - 如何从字符串输入中删除逗号
- sql - 在 SQL Server 中创建递归函数
- java - 简单的 AsyncTasc - 更好的解决方案 - 防止内存泄漏
- raspberry-pi - 通过 T-Mobile GSM SIM 与 SIM800 板和 SAKIS3G 连接 Raspberry Pi-3