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/27 16:42] – [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 108: | Line 89: | ||
| </ | </ | ||
| - | example3 with linked plugin | + | ==== Add java sources and native C++ support ==== |
| - | < | + | |
| - | ionic start GianoDroidHybrid blank --id org.csgalileo.gianodroidhybrid | + | |
| - | cd GianoDroidHybrid | + | |
| - | ionic cordova platform add android | + | |
| - | ionic cordova plugin add --link ../ | + | |
| - | </ | + | |
| - | ==== Android Studio ==== | + | Add opencv support http:// |
| - | After project | + | In <project |
| + | CMakeLists.txt | ||
| + | < | ||
| + | cmake_minimum_required(VERSION 3.4.1) | ||
| + | set(CMAKE_VERBOSE_MAKEFILE on) | ||
| + | find_library(log-lib log) | ||
| - | 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' | + | set(OpenCV_DIR " |
| - | ==== Eclipse ==== | + | find_package(OpenCV REQUIRED) |
| + | message(STATUS " | ||
| + | </ | ||
| - | $P is $NAME/platforms/android path | + | and add to // |
| + | < | ||
| + | android | ||
| + | externalNativeBuild { | ||
| + | cmake { | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | // edit also abiFilters and clean project before make apk | ||
| + | //exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | } | ||
| - | * Import -> " | + | } |
| - | * Project -> Build Path -> Configure Build Path | + | |
| - | * Source -> Link source -> $P/ | + | |
| - | * Libraries -> Add external JAR -> $P/ | + | |
| - | * Libraries -> Add external JAR -> $P/ | + | |
| - | ==== Native lib integration ==== | + | dependencies { |
| + | compile project(': | ||
| + | } | ||
| - | Create zip file named **gpio.jar** and put into platforms/android/libs | + | ext.postBuildExtras = { |
| - | < | + | logger.quiet(' |
| - | lib | + | android { |
| - | └── armeabi | + | sourceSets { |
| - | | + | main.java.srcDirs += ' |
| - | </code> | + | |
| + | } | ||
| + | } | ||
| + | } | ||
| + | </file> | ||
| - | build.gradle | + | from build.gradle |
| - | ===== Tips ===== | + | < |
| + | dependencies { | ||
| + | //classpath ' | ||
| - | ==== Video fullscreen autoplay | + | // 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(' | ||
| - | }); | ||
| - | </ | ||