一键构建PhoneGap构建到Android

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一键构建PhoneGap构建到Android相关的知识,希望对你有一定的参考价值。

Basically allows for a one click build through a repository driving PhoneGap Build project.
  1. #! /bin/sh
  2.  
  3. project="[phonegap projectnumber]";
  4. username="[phonegap username]";
  5. password="[phonegap password]";
  6. appPath="[path to www folder]";
  7. projectPath="[path where you want the apk file]";
  8.  
  9. APIPATH="https://build.phonegap.com/api/v1/apps";
  10. FILEPATH="https://build.phonegap.com/apps/";
  11.  
  12. APIcall="$APIPATH/$project"
  13. creds="$username:$password";
  14.  
  15. ##commit changes
  16. echo "Forcing changes to github";
  17. cd $appPath
  18. null=$(git commit -m "auto commit as part of script");
  19. null=$(git push origin master);
  20. echo "Done";
  21.  
  22. cd $projectPath
  23.  
  24. ##Request Phonegap data
  25. echo "Requesting Project Data.";
  26. package=$(curl -s -u $creds $APIcall | grep -Po '"package":.*?[^\],');
  27. title=$(curl -s -u $creds $APIcall | grep -Po '"title":.*?[^\],');
  28. title=${title##*:};
  29. title=$(echo $title|sed 's/,//g');
  30. title=$(echo $title|sed 's/"//g');
  31. package=${package##*:};
  32. package=$(echo $package|sed 's/,//g');
  33. package=$(echo $package|sed 's/"//g');
  34. echo "Done. ";
  35.  
  36. ##Request Rebuild
  37. echo "Requesting Rebuild.";
  38. request=$(curl -s -u $creds -X PUT -d 'data={"pull":"true"}' $APIcall);
  39. echo "Done. ";
  40. donecheck="";
  41.  
  42.  
  43. echo " Waiting for rebuild to be done.";
  44. while [$donecheck -eq ""]
  45. do
  46. echo ".";
  47. sleep 10;
  48. donecheck=$(curl -s -u $creds $APIcall | grep -Po '"android":"complete"');
  49. done
  50. echo "Done. Now downloading. ";
  51.  
  52. ##Download File
  53. download=$(curl -L -s -u $creds -o $title-debug.apk $FILEPATH/$project/download/android);
  54.  
  55. ##Install on Device
  56. ~/Downloads/android-sdk/platform-tools/adb uninstall $package
  57. ~/Downloads/android-sdk/platform-tools/adb install -r ./$title-debug.apk

以上是关于一键构建PhoneGap构建到Android的主要内容,如果未能解决你的问题,请参考以下文章

Phonegap 构建 facebook 连接插件 (android)

ngInclude 在 Android 的 PhoneGap 构建中失败

Phonegap 构建 - Facebook 连接插件 - 无效的 android_key 参数错误

如何将 Google 广告添加到 PhoneGap 构建的应用程序?

PhoneGap Cordova 构建错误退出代码 2

Phonegap/Cordova 代码在构建时不断重置