This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tips:ionic [2017/07/27 10:16] – [Android] 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> | + | |
| - | . $LIB/ | + | |
| - | </ | + | |
| - | + | ||
| - | <code bash> | + | |
| - | NAME=PeperStart | + | |
| - | ionic start $NAME blank | + | |
| - | cd $NAME | + | |
| - | ionic browser add crosswalk #(this command enable also android platform) | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Update libs ==== | + | |
| <code bash> | <code bash> | ||
| Line 65: | Line 46: | ||
| </ | </ | ||
| - | ==== Android ==== | + | ===== Android |
| It is important to install native gradle or use gradle shipped with android studio (see PATH below) | It is important to install native gradle or use gradle shipped with android studio (see PATH below) | ||
| Line 91: | Line 72: | ||
| </ | </ | ||
| - | example2 | + | example2 |
| < | < | ||
| ionic start MyCameraApp blank --id org.csgalileo.mycameraapp | ionic start MyCameraApp blank --id org.csgalileo.mycameraapp | ||
| Line 107: | Line 88: | ||
| ionic cordova run android --device | ionic cordova run android --device | ||
| </ | </ | ||
| - | ==== Eclipse ==== | ||
| - | $P is $NAME/ | + | ==== Add java sources and native C++ support ==== |
| - | * Import -> " | + | Add opencv support http://wiki.csgalileo.org/projects: |
| - | * Project -> Build Path -> Configure Build Path | + | |
| - | * Source -> Link source -> $P/ | + | |
| - | * Libraries -> Add external JAR -> $P/Cordovalib/xwalk_core_library/ | + | |
| - | * Libraries -> Add external JAR -> $P/Cordovalib/ | + | |
| - | ==== Native | + | In <project root> add: |
| + | CMakeLists.txt | ||
| + | < | ||
| + | cmake_minimum_required(VERSION 3.4.1) | ||
| + | set(CMAKE_VERBOSE_MAKEFILE on) | ||
| + | find_library(log-lib log) | ||
| - | Create zip file named **gpio.jar** and put into platforms/android/libs | + | set(OpenCV_DIR "android-opencv/opencv/ |
| - | < | + | find_package(OpenCV REQUIRED) |
| - | lib | + | message(STATUS " |
| - | └── armeabi | + | </file> |
| - | └── libgpio.so | + | |
| - | </code> | + | |
| - | build.gradle | + | and add to //build-extras.gradle// (this file is copied with hook <hook src=" |
| - | ===== Tips ===== | + | < |
| + | android { | ||
| + | externalNativeBuild { | ||
| + | cmake { | ||
| + | path " | ||
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | // edit also abiFilters and clean project before make apk | ||
| + | //exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | } | ||
| - | ==== 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(' | ||
| - | }); | ||
| - | </ | ||