Android Studio安装失败,APK未签名 [英] Installation failed with Android Studio, APK not signed

查看:1461
本文介绍了Android Studio安装失败,APK未签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近从Eclipse转到Android Studio,我也将JDK从 java-open-jdk 更改为 jdk1.7.0_45



现在我正在尝试运行我的第一个应用程序,并收到以下消息:

安装由于APK未签名或签名不正确,因此失败。 
如果这是一个基于Gradle的项目,那么确保在Gradle构建脚本中指定了签名配置

编辑:



当我从Android Studio运行时,出现上面显示的错误。当我从命令行运行它时,我没有收到错误(该应用程序正在运行,并且出现错误,但与Gradle无关)。



我从这里获得了代码



您可以在 google repo

UPDATE 2 :

我添加了这段代码

  signingConfigs { 
发布{
storeFile文件(john.keystore)
storePasswordjohn
keyAliasjohnkeystore
keyPasswordjohn
}

$ / code>

就在 buildTypes 代码之上阻止build.gradle文件。
文件john.keystore位于我的项目的根目录下。我正在运行 gradlew assembleRelease ,我得到了一个 xxx-release-unsigned.apk

解决方案

如果确实使用gradle运行构建,则需要配置 signingConfigs 。 Android可以自动配置您的调试signingConfig。您可以通过下列方式发布 signingConfig

  android {

signingConfigs {

发布{

storeFile文件('android.keystore')
storePasswordpwd
keyAlias别名
keyPasswordpwd

}

buildTypes {

版本{

signingConfig signingConfigs .release
}
}
}

查看手册这里的主题: http:// tools。 android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations



如果您仍有问题,请更新问题与您的 build.gradle 。最可能的问题是铺设在这里。我使用的JDK 1.7和gradle builds工作正常。

Recently change to Android Studio from Eclipse and I have also changed the JDK from java-open-jdk to jdk1.7.0_45.

Now I'm trying to run my first app and I get this message:

Installation failed since the APK was either not signed, or signed incorrectly.
If this is a Gradle-based project, then make sure the signing configuration 
is specified in the Gradle build script

Edit:

When I'm running from Android Studio I get the error displayed above. When I'm running it from the command line I don't get an error (well the app is running and I get an error but nothing to do with gradle).

I got the code from here

You can check build.gradle here at google repo

UPDATE 2:

I added this code

signingConfigs {
    release {
        storeFile file("john.keystore")
        storePassword "john"
        keyAlias "johnkeystore"
        keyPassword "john"
    }
}

just above the buildTypes code block in the build.gradle file. File john.keystore is on the root of my Project. I'm running gradlew assembleRelease and I'm getting a xxx-release-unsigned.apk.

解决方案

If you indeed runing build with gradle you need to configure signingConfigs. Android can configure your debug signingConfig automatically. You can make release signingConfig in a next manner:

android {

    signingConfigs {

        release {

            storeFile file('android.keystore')
            storePassword "pwd"
            keyAlias "alias"
            keyPassword "pwd"
        }
    }

    buildTypes {

       release {

           signingConfig signingConfigs.release
       }
    }
}

Check manual on this topic here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations

If you still have issues, please update question with your build.gradle. Most likely issue is laying here. I'm using JDK 1.7 and gradle builds are working fine.

这篇关于Android Studio安装失败,APK未签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆