Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| tips:ionic [2017/07/26 17:11] – [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 90: | Line 71: | ||
| ionic cordova run android --device | ionic cordova run android --device | ||
| </ | </ | ||
| - | ==== Eclipse ==== | ||
| - | $P is $NAME/platforms/ | + | example2 with cordova-plugin-camera-preview.git -> GianoDroidIonic |
| + | < | ||
| + | ionic start MyCameraApp blank --id org.csgalileo.mycameraapp | ||
| + | git clone --depth=1 https://github.com/ | ||
| + | cd MyCameraApp | ||
| + | ionic cordova platform add android | ||
| - | * Import -> " | + | ionic cordova plugin add ../cordova-plugin-camera-preview |
| - | * Project | + | npm install @ionic-native/camera-preview |
| - | * Source | + | |
| - | * Libraries | + | |
| - | * Libraries -> Add external JAR -> $P/ | + | |
| - | ==== Native lib integration ==== | + | ionic cordova plugin add cordova.plugins.diagnostic |
| + | npm install @ionic-native/ | ||
| - | Create zip file named **gpio.jar** and put into platforms/android/libs | + | ionic cordova build android |
| - | < | + | ionic cordova run android --device |
| - | lib | + | |
| - | └── armeabi | + | |
| - | └── libgpio.so | + | |
| </ | </ | ||
| - | build.gradle search inside libs for *jar (see dependancy section) | + | ==== Add java sources and native C++ support |
| - | ===== Tips ===== | + | |
| - | ==== Video fullscreen autoplay | + | Add opencv support http:// |
| + | |||
| + | In <project root> add: | ||
| + | CMakeLists.txt | ||
| + | < | ||
| + | cmake_minimum_required(VERSION 3.4.1) | ||
| + | set(CMAKE_VERBOSE_MAKEFILE on) | ||
| + | find_library(log-lib log) | ||
| + | |||
| + | set(OpenCV_DIR " | ||
| + | find_package(OpenCV REQUIRED) | ||
| + | message(STATUS " | ||
| + | </ | ||
| + | |||
| + | and add to // | ||
| + | < | ||
| + | android { | ||
| + | externalNativeBuild { | ||
| + | cmake { | ||
| + | path " | ||
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | // edit also abiFilters and clean project before make apk | ||
| + | //exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | 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(' | ||
| - | }); | ||
| - | </ | ||