Cordova | No pain,No gain. https://ufirst.jp/memo Sun, 28 Oct 2018 12:30:22 +0000 ja hourly 1 https://wordpress.org/?v=6.9.4 https://i0.wp.com/ufirst.jp/memo/wp-content/uploads/2022/08/apple-touch-icon-76x76-precomposed.png?fit=32%2C32&ssl=1 Cordova | No pain,No gain. https://ufirst.jp/memo 32 32 126496119 cordova build android したらgradle: Command failed with exit code EACCES となった件 https://ufirst.jp/memo/2018/10/cordova-build-android-%e3%81%97%e3%81%9f%e3%82%89gradle-command-failed-with-exit-code-eacces-%e3%81%a8%e3%81%aa%e3%81%a3%e3%81%9f%e4%bb%b6/ https://ufirst.jp/memo/2018/10/cordova-build-android-%e3%81%97%e3%81%9f%e3%82%89gradle-command-failed-with-exit-code-eacces-%e3%81%a8%e3%81%aa%e3%81%a3%e3%81%9f%e4%bb%b6/#respond Sun, 28 Oct 2018 12:30:22 +0000 https://ufirst.jp/memo/?p=1779 $ cordova build android ANDROID_HOME=/Users/user/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home /Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle: Command failed with exit code EACCES
gradle: Command failed with exit code EACCES

とは、なんだ?
試しに、以下をエラーになったgradleを実行してみた。

$ "/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle"
bash: /Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle: Permission denied

権限が無いらしい。それならと、

$ chmod +x "/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle"
$ cordova build android

これで成功

]]>
https://ufirst.jp/memo/2018/10/cordova-build-android-%e3%81%97%e3%81%9f%e3%82%89gradle-command-failed-with-exit-code-eacces-%e3%81%a8%e3%81%aa%e3%81%a3%e3%81%9f%e4%bb%b6/feed/ 0 1779
iOSでRefused to load gap://ready because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy. エラー https://ufirst.jp/memo/2016/09/ios%e3%81%a7refused-to-load-gapready-because-it-appears-in-neither-the-child-src-directive-nor-the-default-src-directive-of-the-content-security-policy-%e3%82%a8%e3%83%a9%e3%83%bc/ https://ufirst.jp/memo/2016/09/ios%e3%81%a7refused-to-load-gapready-because-it-appears-in-neither-the-child-src-directive-nor-the-default-src-directive-of-the-content-security-policy-%e3%82%a8%e3%83%a9%e3%83%bc/#comments Fri, 16 Sep 2016 13:57:55 +0000 http://home.uchida.asia/memo/?p=722 Cordovaで開発したアプリをiOS10で実行すると以下のエラー(iOS9までは正常に動いていた)

Refused to load gap://ready because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy.
HTMLを以下の通り修正
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
↓
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src * 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
default-srcに「gap://ready file:」を追加する必要があるようだ。
]]>
https://ufirst.jp/memo/2016/09/ios%e3%81%a7refused-to-load-gapready-because-it-appears-in-neither-the-child-src-directive-nor-the-default-src-directive-of-the-content-security-policy-%e3%82%a8%e3%83%a9%e3%83%bc/feed/ 1 722
Cordovaでリリース用APKの作成 https://ufirst.jp/memo/2016/07/cordova%e3%81%a7%e3%83%aa%e3%83%aa%e3%83%bc%e3%82%b9%e7%94%a8apk%e3%81%ae%e4%bd%9c%e6%88%90/ https://ufirst.jp/memo/2016/07/cordova%e3%81%a7%e3%83%aa%e3%83%aa%e3%83%bc%e3%82%b9%e7%94%a8apk%e3%81%ae%e4%bd%9c%e6%88%90/#respond Fri, 01 Jul 2016 08:44:02 +0000 http://home.uchida.asia/memo/?p=709 こちらにすべて掲載されている
素晴らしい
http://phiary.me/cordova-android-release-build-apk-for-google-play/

]]>
https://ufirst.jp/memo/2016/07/cordova%e3%81%a7%e3%83%aa%e3%83%aa%e3%83%bc%e3%82%b9%e7%94%a8apk%e3%81%ae%e4%bd%9c%e6%88%90/feed/ 0 709
Cordovaでファイルのダウンロード https://ufirst.jp/memo/2016/06/cordova%e3%81%a7%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89/ https://ufirst.jp/memo/2016/06/cordova%e3%81%a7%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89/#respond Wed, 29 Jun 2016 05:46:02 +0000 http://home.uchida.asia/memo/?p=705
PhoneGapでサーバーから画像・音声・動画をダウンロードして表示・再生まで - Qiita
追記:2020年2月現在の自己メモ 現在のプラグインインストールコマンドは以下です。 ※ PhoneGapは、動向がよくわからないため、Cordova推奨です。 cordova plugin add cordova-plugin-file-transfer 記事執筆時は...
]]>
https://ufirst.jp/memo/2016/06/cordova%e3%81%a7%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89/feed/ 0 705
cordovaでsqlite https://ufirst.jp/memo/2016/06/cordova%e3%81%a7sqlite/ https://ufirst.jp/memo/2016/06/cordova%e3%81%a7sqlite/#respond Mon, 27 Jun 2016 13:14:05 +0000 http://home.uchida.asia/memo/?p=701 https://www.npmjs.com/package/cordova-plugin-sqlite
$cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage
にてプラグインの導入は完了

]]>
https://ufirst.jp/memo/2016/06/cordova%e3%81%a7sqlite/feed/ 0 701
Cordovaのコマンド関係 https://ufirst.jp/memo/2016/06/cordova%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e9%96%a2%e4%bf%82/ https://ufirst.jp/memo/2016/06/cordova%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e9%96%a2%e4%bf%82/#respond Mon, 27 Jun 2016 05:36:05 +0000 http://home.uchida.asia/memo/?p=691 iOSエミュレータのインストール
 
プロジェクトの作成 -dオプションで途中経過が表示される

$ cordova create hogehoge hoge.hoge.com Hoge -d
cd hoge

iOS,Androidプラットフォーム用のプロジェクトファイルを追加

cordova platform add ios
cordova platform add android
バージョンを指定する場合
$ cordova platform add android@4.4.4

対象の存在するプラットフォームを確認する

cordova platform ls

ブラウザで動作確認

$ cordova serve android
Static file server running on port 8000 (i.e. http://localhost:8000)
CTRL + C to shut down

ビルド

$ cordova build            # 全でプラットフォームを一気に生成
$ cordova build android    # プラットフォーム個別
$ cordova build --release  # リリース要
]]>
https://ufirst.jp/memo/2016/06/cordova%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e9%96%a2%e4%bf%82/feed/ 0 691
MacでCordova環境構築 https://ufirst.jp/memo/2016/06/mac%e3%81%a7cordova%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89/ https://ufirst.jp/memo/2016/06/mac%e3%81%a7cordova%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89/#respond Fri, 24 Jun 2016 13:06:56 +0000 http://home.uchida.asia/memo/?p=677 Nodejsをインストール
https://nodejs.org/
インストーラー(pkg)を実行しインストール

$ node -v
v4.4.6
$ npm -v
2.15.5

cordovaのインストール

gオプション(グローバル領域)をつけてnpmでインストール
$ npm install cordova -g

以下のエラーが発生する

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cordova'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cordova']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/cordova',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/cordova',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
$ sudo chmod 777 /usr/local/lib/node_modules/

再度インストール実行

$ npm install cordova -g

更に以下のエラー

npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/cordova/bin/cordova' -> '/usr/local/bin/cordova'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, symlink '../lib/node_modules/cordova/bin/cordova' -> '/usr/local/bin/cordova']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/cordova/bin/cordova',
npm ERR!   dest: '/usr/local/bin/cordova' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
$ sudo chmod 777 /usr/local/bin/

インストール成功

$ cordova -v
? May Cordova anonymously report usage statistics to improve the tool over time? Yes
Thanks for opting into telemetry to help us improve cordova.
6.2.0

Android Studioをインストール
インストール後パスを通しておく

vi ~/.bash_profile

以下を記載する

export PATH=$HOME/Library/Android/sdk/platform-tools:$PATH
export PATH=$HOME/Library/Android/sdk/tools:$PATH

パスを反映

$ source ~/.bash_profile

実行

android -h
$ adb version
Android Debug Bridge version 1.0.36
Revision fd9e4d07b0f5-android
]]>
https://ufirst.jp/memo/2016/06/mac%e3%81%a7cordova%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89/feed/ 0 677