brodycj / cordova-sqlite-test-app

4 stars 6 forks source link

How to test with Ionic #5

Open peterennis opened 6 years ago

peterennis commented 6 years ago

I am testing Ionic 4. Typically using package.json with npm install . . . I am using Windows for development and would like to do initial testing of the SQLite plugin. However I do not know where to start after checking the README etc. I read through the other plugin permutations and it did not help. Is there some other document? My interest in the new plugin version working as a component (Stencil). Pointers appreciated.

peterennis commented 6 years ago

I found this: https://beta.ionicframework.com/docs/native/sqlite#installation

$ ionic cordova platform add
$ ionic cordova plugin add cordova-sqlite-storage
$ npm install --save @ionic-native/sqlite

Running cordova prepare showed the following output but made no changes in the ionic project.

C:\ae\adaept.com\aesql>cordova prepare
Android Studio project detected
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
Installing "cordova-plugin-device" for android
Discovered plugin "cordova-plugin-splashscreen" in config.xml. Adding it to the project
Installing "cordova-plugin-splashscreen" for android
Discovered plugin "cordova-plugin-ionic-webview" in config.xml. Adding it to the project
Installing "cordova-plugin-ionic-webview" for android
Discovered plugin "cordova-plugin-ionic-keyboard" in config.xml. Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for android

C:\ae\adaept.com\aesql>

It is your plugin :) I have installed it in an "@ionic/angular": "^4.0.0-beta.2" project here: https://github.com/peterennis/aesql

C:\ae\adaept.com\aesql>cordova run android
Android Studio project detected
ANDROID_HOME=C:\Users\peter\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_161
studio
:wrapper

BUILD SUCCESSFUL

Total time: 10.138 secs
Subproject Path: CordovaLib
Subproject Path: app
Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
.................................................................................................................................................................
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 26.0.2].

This SO solution: https://stackoverflow.com/questions/40383323/cant-accept-license-agreement-android-sdk-platform-24/40383457#40383457

mkdir "%ANDROID_HOME%\licenses"
echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"

Then try again:

C:\ae\adaept.com\aesql>cordova run android
Android Studio project detected
ANDROID_HOME=C:\Users\peter\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.0.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Checking the license for package Android SDK Build-Tools 26.0.2 in C:\Users\peter\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.
Checking the license for package Android SDK Platform 26 in C:\Users\peter\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
(node:65772) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
    at ChildProcess.whenDone (C:\ae\adaept.com\aesql\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:65772) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:65772) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

C:\ae\adaept.com\aesql>

It seems to complain about the Android version.

brodycj commented 6 years ago

This project is not designed to work with Angular or Ionic. I will document this when I get a chance.

peterennis commented 6 years ago

Thanks for the Info. Should I open a ticket upstream with Ionic to this effect once you have made the note? Is there a different project that should be used?

brodycj commented 6 years ago

Should I open a ticket upstream with Ionic to this effect once you have made the note?

I would be grateful if you want to do this now. I do very limited testing and support for Ionic and Angular.

This project and related projects [1] and [2] are simplistic starter points meant to help people either get started or reproduce issues as quickly as possible. Very similar to using "create-react-app" to start developing a React app. I have not seen such a good one for Ionic or Angular.

Is there a different project that should be used?

There is Ionic3-predb but it looks like you need to do some additional prep work to get started.

[1] https://github.com/brodybits/cordova-sqlite-storage-starter-app [2] https://github.com/brodybits/cordova-sqlite-ext-bootstrap-starter-app