首页 > 解决方案 > 该软件包似乎已损坏(但通过电报安装)

问题描述

在从文件管理器在 android 设备上安装我的 apk 文件时,我遇到了一个非常奇怪的问题,一些信息是:

  1. 我在 android studio v.3.4.2 中构建签名的 apk
  2. 由 jarsigner 测试验证,没有错误
  3. 使用 V1 和 V2 签名构建(没有区别)
  4. 测试调试模式 apk 并同时发布
  5. 目标 sdk 为 25 (android 7.1.1)
  6. 我检查了“未知的 apk 安装”并且已启用
  7. 我检查了文件管理器安装 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'
}

标签: android

解决方案


推荐阅读