简体   繁体   English

如何在没有Android Studio的情况下签署Android APK

[英]How to sign android apk without android studio

我在此问题上发现了许多令人困惑的答案:如何在没有Android Studio的情况下签署(发布/调试)Android应用程序(例如,在签署ionic / cordova / phonegap应用程序时签署)?

You can Add Key store in Gradle file. 您可以在Gradle文件中添加密钥存储。

 android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}

--> use CMD for generate signed APK. ->使用CMD生成签名的APK。

gradlew assemblerelease.

So, the right and simple answer to date is: 因此, 迄今为止 ,正确而简单的答案是:

  1. cd into your project platform/android folder (might just be your main project folder if not cordova/ionic build). cd进入您的项目platform / android文件夹(如果不是cordova / ionic build,则可能只是您的主项目文件夹)。 You should find your main build.gradle file in that folder. 您应该在该文件夹中找到您的主要build.gradle文件。
  2. Create a keystore file by calling: 通过调用以下命令创建密钥库文件:

    \nkeytool -genkey -v -keystore .keystore -alias -keyalg RSA -keysize 2048 -validity 10000 keytool -genkey -v -keystore .keystore -alias -keyalg RSA -keysize 2048 -validity 10000\n

    Follow along and fill in and passwords (write them down in a place you'll find them!) 继续并填写和密码(在您会发现它们的地方写下它们!)

  3. Create two files named: debug-signing.properties and release-signing.properties 创建一个名为两个文件: debug-signing.propertiesrelease-signing.properties

  4. Enter the following configuration to both (you can later change the keystore to harden the security for release build...): 为两者输入以下配置(您以后可以更改密钥库以增强发行版的安全性...):

    \nkeyAlias=ALIAS_NAME keyAlias = ALIAS_NAME\nkeyPassword=ALIAS_PASSWORD keyPassword = ALIAS_PASSWORD\nstoreFile=KEYSTORE_FILE_NAME storeFile = KEYSTORE_FILE_NAME\nstorePassword=KEYSTORE_PASSWORD` storePassword = KEYSTORE_PASSWORD`\n
  5. Run build ... 运行构建...

Ionic team giving a great idea about this query you can follow this link and you can do this with in 10 min's Ionic小组针对此查询提供了一个不错的主意,您可以点击此链接,并且可以在10分钟内完成此操作

http://ionicframework.com/docs/guide/publishing.html http://ionicframework.com/docs/guide/publishing.html

But You need android sdk to do this ... 但是您需要android sdk来做到这一点...

To set ANDROID_HOME 设置ANDROID_HOME

Windows 视窗

set ANDROID_HOME=Path to sdk 

Linux Based Systems 基于Linux的系统

export ANDROID_HOME=Path to sdk

Steps to Follow 遵循的步骤

  1. Create release app 创建发布应用

  2. Create keystore 创建密钥库

  3. Signing the APK 签署APK

I had the same problem. 我有同样的问题。 The easiest solution is to come back to the fundamentals through the DOS commands keytool and jarsigner. 最简单的解决方案是通过DOS命令keytool和jarsigner返回基础知识。 Note that these files must be located in the jdk directory to work well. 请注意,这些文件必须位于jdk目录中才能正常工作。

Only two actions to do: 仅需执行两个操作:
- to use keytool for creating your keystore and your certificate(s):the first certificate is created when you create the single keystore. -使用keytool创建密钥库和证书时:创建单个密钥库时将创建第一个证书。 Then, the other certificates will be created by calling again the keytool command with the same keystore name 然后,将通过再次调用具有相同密钥库名称的keytool命令来创建其他证书
- then to use jarsigner. -然后使用jarsigner。 Prefer to differentiate the jar input filename and the generated signed jar filename when you prepare your jarsigner command 在准备jarsigner命令时,最好区分 jar输入文件名和生成的签名 jar文件名

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

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