简体   繁体   English

生成已签名的 apk 不起作用,apk 未签名

[英]generate signed apk is not working, apk is unsigned

I used to generate a signed apk from Android Studio and everything was working well until I updated Android Studio to 3.3 .我曾经从 Android Studio 生成签名的 apk 并且一切正常,直到我将 Android Studio 更新到3.3 It generates an apk but after I try to install it, it says: App Not Installed!它生成一个apk,但在我尝试安装它后,它说:应用程序未安装!

My Trial was by:我的试验是通过:

  1. Click on build点击build
  2. Generate Signed Apk生成签名的 Apk
  3. Choose APK and click Next选择APK并点击下一步
  4. Insert the Key Store Path, Key Store Password, Key Alias, Key Password插入密钥库路径、密钥库密码、密钥别名、密钥密码
  5. Click Next点击下一步
  6. Choose Release Variant选择发布变体
  7. Click Finish单击完成

The Apk is generated but it's not signed! Apk 已生成但未签名! What is the problem ?问题是什么 ?

这是在尝试上传到测试版之后

Here is my app build.gradle这是我的应用程序build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    useLibrary 'org.apache.http.legacy'
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.twobreathe.soft2breathe"
        minSdkVersion 23
        targetSdkVersion 27
        versionCode 9
        versionName "1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
        vectorDrawables {
            useSupportLibrary true
        }
        resConfigs "en", "ja"
    }
    signingConfigs {
        release {
            keyAlias "[my key alias]"
            keyPassword "[my key password]"
            storeFile file("[path to the keystore file]")
            storePassword "[my store password]"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            shrinkResources true
            pseudoLocalesEnabled false
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
        }


    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/fluidsynth/android/CMakeLists.txt"
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    dataBinding {
        enabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildToolsVersion '28.0.3'
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.github.parse-community.Parse-SDK-Android:parse:1.18.4'
    implementation 'com.jjoe64:graphview:4.2.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.orhanobut:hawk:2.0.1'
    implementation 'xyz.sahildave:arclayout:1.0.0'
    implementation 'com.mikhaellopez:circularprogressbar:2.0.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.github.GrenderG:Toasty:1.3.0'
    implementation 'com.kyleduo.switchbutton:library:2.0.0'
    implementation 'com.github.franmontiel:LocaleChanger:0.9.2'
    implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
}

After updating to 3.3, many problems are occuring related to signing an APK.更新到 3.3 后,出现很多与签署 APK 相关的问题。 Sometime it doesn't sign the apk and sometime it says the key is not private.有时它不签署 apk,有时它说密钥不是私有的。

Well i also faced this problem after upgrading to android studio 3.3 and i resolved in 3 steps.好吧,我在升级到 android studio 3.3 后也遇到了这个问题,我分 3 个步骤解决了。 But firstly make sure you backup your whole project.但首先要确保备份整个项目。

  1. In Android Studio goto File > Project Structure and untick from "use embedded JDK" then click OK在 Android Studio 中,转到 File > Project Structure 并取消选中“use Embedded JDK”,然后单击 OK
  2. Goto Computer Settings (system settings) (win + pause key) then go to Advanced system settings>Environment variables.转到计算机设置(系统设置)(win + 暂停键)然后转到高级系统设置>环境变量。 if JAVA_HOME not present then add it and set path to your installed JDK.如果 JAVA_HOME 不存在,则添加它并设置已安装 JDK 的路径。
    As i couldn't find a direct approach to modify jdk path in my project that is upgraded in some way to android studio 3.3 settings, i did following(for the last step) BUT MAKE SURE YOU MAKE BACKUP BEFORE THIS.由于我找不到在我的项目中以某种方式升级到 android studio 3.3 设置的直接方法来修改 jdk 路径,我做了以下(最后一步)但请确保在此之前进行备份。
  3. To make sure where i am guiding come to project view, I deleted ".grade", ".idea", "capture", "gradle" folders from the root and "build", "release", "lib" folder from "app" leaving "src" as it is.为了确保我在指导项目视图中的位置,我从根目录中删除了“.grade”、“.idea”、“capture”、“gradle”文件夹和“build”、“release”、“lib”文件夹。 app”保留“src”原样。 Deleted root.iml and did not delete app.iml file Then rebuild the project and then created the Signed package.删除了root.iml并没有删除app.iml文件然后重建项目,然后创建了Signed包。

It went successful after 2 try.经过2次尝试成功。 To be very honest i did the last step twice by restoring files from backup.老实说,我通过从备份恢复文件做了两次最后一步。 As deleting these folders i messed up 1 time.删除这些文件夹时,我搞砸了 1 次。

Not strictly related, but I ended up in this questions when searching for a fix to my problem.不是严格相关的,但在寻找解决我的问题的方法时,我最终遇到了这个问题。 In my case I forgot to remove 'debuggable true' for one of my non-debug built-types.在我的情况下,我忘记为我的一种非调试内置类型删除“debuggable true”。 When I was generating the bundle the google play store wouldn't complain about it just said that it wasn't signed.当我生成捆绑包时,谷歌游戏商店不会抱怨它只是说它没有签名。 But when I tried uploading an apk it showed the true error.但是当我尝试上传 apk 时,它显示了真正的错误。

From your Gradle its visible that you have not configured your Signing Config with it.从您的 Gradle 中可以看出您尚未使用它配置您的签名配置。

Please check image below:请检查下图:

在此处输入图片说明

Step 1:第1步:

Go to your project settings > select your module (Let's say "app") > go to signing > enter proper information and keystore.jks file转到您的项目设置> 选择您的模块(比方说“应用程序”)> 去签名> 输入正确的信息和 keystore.jks 文件

Step 2:第2步:

Go to Build Types > select Release type > assign signing config as you created on step 1. > after that your gradle will have config as there in image.转到构建类型 > 选择发布类型 > 分配您在步骤 1 中创建的签名配置。 > 之后,您的 gradle 将具有图像中的配置。

Step 3:第 3 步:

Try generating signed APK.尝试生成签名的 APK。

It will be success!!!一定会成功!!!

Happy Coding..快乐编码..

Double check both of the values on the final dialog, labelled by "Signature Versions".仔细检查最终对话框中的两个值,标记为“签名版本”。 For more information please check the following link: https://developer.android.com/about/versions/nougat/android-7.0#apk_signature_v2有关更多信息,请查看以下链接: https : //developer.android.com/about/versions/nougat/android-7.0#apk_signature_v2

Anyway this question seems duplicate as the following: android studio: release apk is not signed无论如何,这个问题似乎重复如下: android studio: release apk is not signed

friend when you go for build the signed apk now in android studio 3.3 , you will 2 option for build the signed apk.朋友,当您现在在 android studio 3.3 中构建已签名的 apk 时,您将有 2 个选项来构建已签名的 apk。 1. Android App Bundle 2.APK 1. 安卓应用程序包 2.APK

i will suggest to use option 2我会建议使用选项 2

select option 2 and Click on Next button now studio ask for your password details now fill all details and select Remember password checkbox for feature and now next .选择选项 2 并单击下一步按钮现在工作室询问您的密码详细信息现在填写所有详细信息并选择记住密码复选框功能,现在下一步。 now again studio ask for debug and release build confirmation now here select release and select 2 checkbox at bottom and then continue现在工作室再次要求调试和发布构建确认,现在在这里选择发布并选择底部的 2 复选框,然后继续

hope your signed apk will be generate .希望您的签名 apk 能够生成。

When generating an APK, make sure both the signature types are checked, otherwise Fabric (and other places) may not recognise it as signed.生成 APK 时,请确保检查了两种签名类型,否则 Fabric(和其他地方)可能无法将其识别为已签名。

Additionally you probably want to remove debuggable true from your release config, as debuggable builds can't be uploaded to Google Play.此外,您可能希望从发布配置中删除debuggable true ,因为无法将可调试版本上传到 Google Play。 There's a chance this is also causing an issue.这也有可能导致问题。

签名选项

Try to sign it using command-line tools.尝试使用命令行工具对其进行签名。 I may help you to identify the problem.我可以帮你找出问题所在。 ( https://developer.android.com/studio/build/building-cmdline ). https://developer.android.com/studio/build/building-cmdline )。

In my case, it was JAVA_HOME problem (as in @Vanshaj Daga answer).就我而言,这是 JAVA_HOME 问题(如@Vanshaj Daga 的回答)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM