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/28 08:15] – [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 custom plugin | + | ==== Add java sources and native C++ support ==== |
- | < | + | |
- | ionic start GianoDroidHybrid blank --id org.csgalileo.gianodroidhybrid | + | |
- | cd GianoDroidHybrid | + | |
- | rm -fR .git | + | |
- | ionic cordova platform add android | + | |
- | ionic cordova plugin add ../ | + | |
- | </code> | + | Add opencv support http:// |
- | ==== Android Studio ==== | + | In <project root> add: |
+ | CMakeLists.txt | ||
+ | < | ||
+ | cmake_minimum_required(VERSION 3.4.1) | ||
+ | set(CMAKE_VERBOSE_MAKEFILE on) | ||
+ | find_library(log-lib log) | ||
- | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder <project-root>/platforms/android | + | set(OpenCV_DIR " |
+ | find_package(OpenCV REQUIRED) | ||
+ | message(STATUS " | ||
+ | </ | ||
- | Now it is possible | + | and add to //build-extras.gradle// (this file is copied with hook < |
- | ==== Eclipse ==== | + | < |
+ | android { | ||
+ | externalNativeBuild { | ||
+ | cmake { | ||
+ | path " | ||
+ | } | ||
+ | } | ||
+ | packagingOptions { | ||
+ | // edit also abiFilters | ||
+ | // | ||
+ | | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | } | ||
- | $P is $NAME/ | + | } |
- | * Import -> " | + | dependencies { |
- | | + | |
- | * Source -> Link source -> $P/ | + | } |
- | * Libraries -> Add external JAR -> $P/ | + | |
- | * Libraries -> Add external JAR -> $P/ | + | |
- | ==== Native lib integration ==== | + | ext.postBuildExtras |
+ | logger.quiet(' | ||
+ | android { | ||
+ | sourceSets { | ||
+ | main.java.srcDirs += ' | ||
+ | main.res.srcDirs += ' | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | Create zip file named **gpio.jar** and put into platforms/android/libs | + | from build.gradle of android-opencv comment classpath from dependancies |
- | <code> | + | <file> |
- | lib | + | dependencies { |
- | └── armeabi | + | //classpath ' |
- | └── libgpio.so | + | |
- | </code> | + | |
- | build.gradle | + | // NOTE: Do not place your application dependencies here; they belong |
- | ===== Tips ===== | + | // in the individual module |
+ | } | ||
+ | </ | ||
- | ==== Video fullscreen autoplay | + | 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(' | ||
- | }); | ||
- | </ |