从CLI运行与--release和自签名应用程序的Phonegap要求我打补丁cordova.js [英] Phonegap run from CLI with --release and self-signed app requires me to patch cordova.js

查看:112
本文介绍了从CLI运行与--release和自签名应用程序的Phonegap要求我打补丁cordova.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我做错了,但我不得不补丁 https://github.com/phonegap/phonegap/blob/master/lib/android/bin/templates/cordova/lib/cordova.js#L313
这种方式(添加未对齐的令牌匹配):

  if(fso.GetExtensionName(path)=='apk'& path.match(/ unaligned /)&&!path.match(/ unsigned /)){
path_to_apk = out_files.item();
break;
}

否则unsignedapk首先被找到并安装,未签名。
我使用CLI来构建和运行我的apk。
在调试模式下,显然是因为签名采用了不同的路径。



Giovanni

解决方案

我不确定您尝试签署您的应用程式时做了什么,但这对我有用:



Update(4/14/14)



在设置正确的配置后,一个命令实际上有一个更简单的方法,在此SO回答中描述: Android版本自动生成版本
我也写了一篇博客文章: http://www.adamwadeharris.com/android-automation/



确保您的应用程式可以使用



确认您已在AndroidManifest .xml。 Google Play将不接受,除非它与商店中的旧版本不同。 versionCode是一个整数值,因此只要每次提交就将其增加1,而不管它是主要更新还是次要更新。 versionName不用于除了显示给用户之外的任何东西,它是一个字符串,所以你可以命名任何你想要的。例如,您可以将其设置为1.0.3,而versionCode可能为3.( http://开发人员。 android.com/tools/publishing/versioning.html#appversioning



http://schemas.android.com/apk/res/android>



创建密钥库文件



创建密钥库文件并设置密码。我不会进入很多关于如何实际这样做的细节。只是确保你不会丢失这个文件。如果您丢失了,并且您必须创建一个新的应用,那么当您尝试将其添加到Google Play商店时,它将成为一个新的应用。 ( http://developer.android.com/tools/publishing/app-signing.html#cert



每个应用程式都必须使用不同的keystore档案,因为它是您将应用程式上传至商店的私人密钥。如果您决定将应用程式转移给其他开发人员,就必须为他们提供密钥库档案,如果您也将其用于其他应用程式,就会出现安全性问题。 ( http://developer.android.com/tools/publishing/app-signing.html #secure-key



将密钥库文件放在计算机上的某个位置。



告诉蚂蚁您的密钥库文件是用于此应用



只需要告诉蚂蚁在哪里的keystore文件是通过去你的android项目文件夹(对于phonegap它在platforms / android)并创建一个ant.properties文件,并在其中添加以下内容:

  key.store = / Users / username / Documents / path / to / my-release-key.keystore 
key.alias = app_name

其中key.store等于从C盘开始的密钥库文件的路径,key.alias只是你想要的简称为。您将在以下命令中使用别名。



构建您的应用程序



打开命令提示符,并导航到您的项目并运行phonegap build。

  phonegap build android 
pre>

在平台/ android / bin中,您应该有:

  AppName.ap_ 
AppName.ap_.d
AppName-debug.apk
AppName-debug-unaligned.apk
AppName-debug-unaligned.apk.d



登录发布模式



然后导航到android目录运行ant版本:

  cd platforms / android 
ant发布
/ pre>

它会提示您输入密钥库密码和别名'app_name'的密码。



在platforms / android / bin中,您现在应该也拥有应用程式的发布版本:

  AppName-release.apk 
AppName-release-unaligned.apk
AppName-release-unsigned.apk
AppName-release- unsigned.apk.d

现在移动到bin目录:

  cd bin 

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore / Users / username / Documents / path / to / my-release -key.keystore AppName-release-unsigned.apk app_name

更新 - 根据下面的注释,如果您使用-sigalg SHA1withDSA -digestalg SHA1而不是SHA1withRSA



输入您的密钥库密码,您将不会在下一步获得警告



  jarsigner -verify -verbose -certs AppName-release-unsigned.apk 

如果你得到这样的警告,忽略它:
警告:此jar包含其证书链未验证的条目。

  zipalign -v 4 AppName-release-unsigned.apk AppName.apk 

它会说:
验证成功



最后的apk(AppName.apk) 。



http:// developer .android.com / tools / publishing / app-signing.html#releasemode



然后您可以上传到Google Play。



我希望这有助于。如有任何问题,请与我们联络。



http://www.adamwadeharris.com/sign-publish-phonegap-app-google-play-store-windows/


I suppose I'm doing something wrong but I had to patch https://github.com/phonegap/phonegap/blob/master/lib/android/bin/templates/cordova/lib/cordova.js#L313 this way (add "unaligned" token matching):

if (fso.GetExtensionName(path) == 'apk' && !path.match(/unaligned/) && !path.match(/unsigned/)) {
      path_to_apk = out_files.item();
      break;
}

otherwise the "unsigned" apk is first found and installed, and it will fail not being signed. I'm using the CLI to build and run my apk. In debug mode it's ok, obviously, because the signing takes a different path.

Giovanni

解决方案

I'm not sure what you did to try to sign your app, but here's what worked for me:

Update (4/14/14)

There is actually an easier way to do this all in one command once you set up the correct configuration, as described in this SO answer: Automation for Android release build I also, wrote a blog post about it here: http://www.adamwadeharris.com/android-automation/

Make sure your app is good to go

Make sure you’ve set your version number in AndroidManifest.xml. Google Play won’t accept it unless it is different than the previous versions in the store. versionCode is an integer value, so just increment it by 1 each time you submit regardless of whether it’s a major or minor update. versionName isn’t used for anything except for displaying to users and it’s a string so you can name it whatever you want. For example, you could set it to 1.0.3 while versionCode might be 3. (http://developer.android.com/tools/publishing/versioning.html#appversioning)

http://schemas.android.com/apk/res/android">

Create a keystore file

Create a keystore file and set a password. I won’t go into a lot of detail about how to actually do this. Just make sure you don’t lose this file. If you lose it, and you have to create a new one, then it will become a new app when you try to add it to the Google Play Store. (http://developer.android.com/tools/publishing/app-signing.html#cert)

Always use a different keystore file for each app because it’s your private key for uploading apps to the store. If you ever decide to transfer your app to another developer, you’ll have to give them the keystore file, and if you also use that keystore for other apps, then you have a security issue. (http://developer.android.com/tools/publishing/app-signing.html#secure-key)

Put the keystore file somewhere on your computer. It doesn’t really matter where.

Tell ant where your keystore file is for this app

Then you just need to tell ant where the keystore file is by going to your android project folder (For phonegap it’s in platforms/android) and create an ant.properties file and put the following in it:

key.store=/Users/username/Documents/path/to/my-release-key.keystore
key.alias=app_name

Where key.store equals the path to the keystore file starting at the C Drive, and key.alias is just whatever you want to call it for short. You’ll use the alias in the following commands.

Build your app

Open up the command prompt, and navigate to your project and run phonegap build.

phonegap build android

in platforms/android/bin you should have:

AppName.ap_
AppName.ap_.d
AppName-debug.apk
AppName-debug-unaligned.apk
AppName-debug-unaligned.apk.d

Sign in release mode

Then navigate to the android directory and run ant release:

cd platforms/android
ant release

It will prompt you for your keystore password and the password for the alias ‘app_name’. Enter your keystore password for both of them.

In platforms/android/bin you should now also have release versions of the app:

AppName-release.apk
AppName-release-unaligned.apk
AppName-release-unsigned.apk
AppName-release-unsigned.apk.d

Now move into the bin directory:

cd bin

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /Users/username/Documents/path/to/my-release-key.keystore AppName-release-unsigned.apk app_name

Update- According to a comment below, you won't get a warning at the next step if you use -sigalg SHA1withDSA -digestalg SHA1 instead of SHA1withRSA

Enter your keystore password

jarsigner -verify -verbose -certs AppName-release-unsigned.apk

If you get a warning like this ignore it: Warning: This jar contains entries whose certificate chain is not validated.

zipalign -v 4 AppName-release-unsigned.apk AppName.apk

it will say: Verification successful

And your final apk (AppName.apk) will be created in the bin directory.

(http://developer.android.com/tools/publishing/app-signing.html#releasemode)

Then you can upload to Google Play.

I hope this helps. Let me know if you have any questions.

http://www.adamwadeharris.com/sign-publish-phonegap-app-google-play-store-windows/

这篇关于从CLI运行与--release和自签名应用程序的Phonegap要求我打补丁cordova.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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