This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tips:ionic [2017/07/26 15:50] – [Create library] scipio | tips:ionic [2017/08/07 13:54] (current) – scipio | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== Prerequisites ===== | ===== Prerequisites ===== | ||
| - | |||
| ==== nodejs (latest) ==== | ==== nodejs (latest) ==== | ||
| Line 19: | Line 18: | ||
| </ | </ | ||
| - | ===== Project ===== | + | ===== Create library |
| - | ==== Create library ==== | + | |
| <code bash> | <code bash> | ||
| Line 37: | Line 35: | ||
| npm update -g ionic cordova | npm update -g ionic cordova | ||
| </ | </ | ||
| - | ==== Create project ==== | ||
| - | * https:// | + | ===== Update libs ===== |
| - | * https:// | + | |
| - | * https:// | + | |
| - | Activate library | ||
| <code bash> | <code bash> | ||
| . $LIB/ | . $LIB/ | ||
| + | npm install -g ionic | ||
| + | |||
| + | cd < | ||
| + | ionic lib update | ||
| </ | </ | ||
| + | ===== Android ===== | ||
| + | |||
| + | It is important to install native gradle or use gradle shipped with android studio (see PATH below) | ||
| + | |||
| + | * ANDROID_HOME=/ | ||
| + | * PATH=/ | ||
| + | |||
| + | example | ||
| <code bash> | <code bash> | ||
| - | NAME=PeperStart | + | nodeenv lib |
| - | ionic start $NAME blank | + | . lib/ |
| - | cd $NAME | + | npm install -g ionic cordova |
| - | ionic browser add crosswalk | + | ionic start test1 blank |
| + | cd test1 | ||
| + | ionic cordova plugin | ||
| + | |||
| + | cd .. | ||
| + | git clone https:// | ||
| + | # create pacakge.json in ImageDetectionCordovaPlugin | ||
| + | cd test1 | ||
| + | cordova plugin add ../ | ||
| + | ionic cordova | ||
| + | ionic cordova build android | ||
| + | ionic cordova run android --device | ||
| </ | </ | ||
| - | ==== Update libs ==== | + | example2 with cordova-plugin-camera-preview.git -> GianoDroidIonic |
| + | < | ||
| + | ionic start MyCameraApp blank --id org.csgalileo.mycameraapp | ||
| + | git clone --depth=1 https:// | ||
| + | cd MyCameraApp | ||
| + | ionic cordova platform add android | ||
| - | <code bash> | + | ionic cordova plugin add ../cordova-plugin-camera-preview |
| - | . $LIB/bin/ | + | npm install |
| - | npm install | + | |
| - | cd < | + | ionic cordova plugin add cordova.plugins.diagnostic |
| - | ionic lib update | + | npm install @ionic-native/ |
| + | |||
| + | ionic cordova build android | ||
| + | ionic cordova run android --device | ||
| </ | </ | ||
| - | ==== Eclipse | + | ==== Add java sources and native C++ support |
| - | $P is $NAME/platforms/ | + | Add opencv support http://wiki.csgalileo.org/ |
| - | * Import -> " | + | In <project root> add: |
| - | * Project -> Build Path -> Configure Build Path | + | CMakeLists.txt |
| - | * Source -> Link source -> $P/ | + | <file> |
| - | * Libraries -> Add external JAR -> $P/ | + | cmake_minimum_required(VERSION 3.4.1) |
| - | * Libraries | + | set(CMAKE_VERBOSE_MAKEFILE on) |
| + | find_library(log-lib log) | ||
| - | ==== Native lib integration ==== | + | set(OpenCV_DIR " |
| + | find_package(OpenCV REQUIRED) | ||
| + | message(STATUS " | ||
| + | </ | ||
| - | Create zip file named **gpio.jar** | + | and add to //build-extras.gradle// |
| - | <code> | + | <file> |
| - | lib | + | android { |
| - | └── | + | externalNativeBuild { |
| - | | + | cmake { |
| - | </code> | + | path " |
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | // edit also abiFilters and clean project before make apk | ||
| + | //exclude 'lib/ | ||
| + | | ||
| + | exclude ' | ||
| + | exclude 'lib/armeabi/ | ||
| + | | ||
| + | | ||
| + | } | ||
| - | build.gradle search inside libs for *jar (see dependancy section) | + | } |
| - | ===== Tips ===== | + | |
| - | ==== Video fullscreen autoplay | + | dependencies { |
| + | compile project(': | ||
| + | } | ||
| + | |||
| + | ext.postBuildExtras | ||
| + | logger.quiet(' | ||
| + | android { | ||
| + | sourceSets { | ||
| + | main.java.srcDirs += ' | ||
| + | main.res.srcDirs += ' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | from build.gradle of android-opencv comment classpath from dependancies | ||
| + | < | ||
| + | dependencies { | ||
| + | //classpath ' | ||
| + | |||
| + | // NOTE: Do not place your application dependencies here; they belong | ||
| + | // in the individual module build.gradle files | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | with <hook src=" | ||
| + | < | ||
| + | include ":" | ||
| + | include ": | ||
| + | include ": | ||
| + | project(": | ||
| + | </ | ||
| + | |||
| + | with <hook src=" | ||
| + | <file xml res/ | ||
| + | < | ||
| + | <param name=" | ||
| + | <param name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | define typescript interface | ||
| + | <file typescript src/ | ||
| + | import { Injectable } from ' | ||
| + | |||
| + | declare var cordova: | ||
| + | |||
| + | @Injectable() | ||
| + | export class TestPlugin { | ||
| + | public testCall() { | ||
| + | cordova.exec( | ||
| + | function(data) { console.log(" | ||
| + | function(error) { console.log(" | ||
| + | " | ||
| + | " | ||
| + | []); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Android Studio ===== | ||
| + | |||
| + | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder < | ||
| + | |||
| + | Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in < | ||
| - | <code html> | ||
| - | <video ng-controller=" | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | <code javascript> | ||
| - | .controller(' | ||
| - | angular.element(' | ||
| - | }); | ||
| - | </ | ||