This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tips:ionic [2017/07/27 12:18] – [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 108: | Line 89: | ||
| </ | </ | ||
| - | ==== Android Studio | + | ==== Add java sources and native C++ support |
| - | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder < | + | Add opencv support http://wiki.csgalileo.org/ |
| - | Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in <project-root>/src and synced with 'ionic build' | + | In <project root> |
| - | ==== Eclipse ==== | + | CMakeLists.txt |
| + | < | ||
| + | cmake_minimum_required(VERSION 3.4.1) | ||
| + | set(CMAKE_VERBOSE_MAKEFILE on) | ||
| + | find_library(log-lib log) | ||
| - | $P is $NAME/platforms/android path | + | set(OpenCV_DIR " |
| + | find_package(OpenCV REQUIRED) | ||
| + | message(STATUS " | ||
| + | </ | ||
| - | * Import | + | and add to //build-extras.gradle// |
| - | * Project | + | < |
| - | | + | android { |
| - | | + | externalNativeBuild { |
| - | | + | cmake { |
| + | path "../ | ||
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | | ||
| + | // | ||
| + | | ||
| + | | ||
| + | exclude 'lib/armeabi/ | ||
| + | | ||
| + | exclude 'lib/x86_64/ | ||
| + | } | ||
| - | ==== Native lib integration ==== | + | } |
| - | Create zip file named **gpio.jar** and put into platforms/android/libs | + | dependencies { |
| - | < | + | compile project(': |
| - | lib | + | } |
| - | └── armeabi | + | |
| - | └── libgpio.so | + | |
| - | </ | + | |
| - | build.gradle search inside libs for *jar (see dependancy section) | + | ext.postBuildExtras = { |
| - | ===== Tips ===== | + | logger.quiet(' |
| + | | ||
| + | sourceSets { | ||
| + | main.java.srcDirs += ' | ||
| + | main.res.srcDirs += ' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| - | ==== Video fullscreen autoplay | + | 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(' | ||
| - | }); | ||
| - | </ | ||