12 กรกฎาคม 2561

build android apk release file using cordova


  • goto the cordova root path
  • generate key file using command >> keytool -genkey -v -keystore YOUR_FILE.jks -keyalg RSA -keysize 2048 -validity 10000 -alias YOUR_ALIAS (example ==> keytool -genkey -v -keystore sample.jks -keyalg RSA -keysize 2048 -validity 10000 -alias sample)
  • move the key file to FILE_NAME.jks path platforms/android/
  • create file platforms/android/release-signing.properties with the following content

storeFile=FILE_NAME.jks
storeType=jks
keyAlias=YOUR_ALIAS
keyPassword=YOUR_PASSWORD
storePassword=YOUR_PASSWORD

  • goto the cordova root path and run >>> cordova build --release


09 กรกฎาคม 2561

convert create-react-app to android/ios mobile application using cordova

steps

  • install jdk 1.8
  • install android studio
  • install gradle by running brew install gradle
  • accept android license by running ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
  • install cordova by running sudo npm install -g cordova
  • create cordova app by running cordova create mycordova
  • goto mycordova cd mycordova
  • create react application inside mycordova by running create-react-app myweb
  • modify myweb/public/index.html like this

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src * data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<title>React App</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="cordova.js"></script>
</body>
</html>



  • modify myweb/package.json like this
{
"name": "sample-app",
"version": "0.1.0",
"private": true,
"homepage": "./", // <- add="" span="">
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && cp -a ./build/. ../www/", // <- add="" span="">
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}

  • inside myweb run npm run build
  • goback to mycordova folder and then run cordova build to generate .apk file or run cordova run andriod to build and run app


บทความยอดนิยม (ล่าสุด)

บทความยอดนิยม (1 ปีย้อนหลัง)