Phonegap-plugin-push added, and now no build for android possible!

Hi there,

regarding to http://docs.ionic.io/docs/push-from-scratch
I added the web client with ionic add ionic-platform-web-client and
I added the push plugin with ionic plugin add phonegap-plugin-push to my project.

I had applied every step from the documentation http://docs.ionic.io/docs/push-from-scratch

If I run ionic run ios --device on my mac for my iPhone, everything is fine. Later I can recive one-time dev-push-notifications I send from my account on http://ionic.io

BUT if I run ionic run android --device on Windows, I’m getting this weird error output:

Running command: "C:\Program Files\nodejs\node.exe" T:\Coding\MyApp\hooks\after_prepare\010_add_platform_class.js T:\Coding\MyApp
add to body class: platform-android
Running command: cmd "/s /c "T:\Coding\MyApp\platforms\android\cordova\run.bat --device""
ANDROID_HOME=C:\Users\itsme\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
Running: T:\Coding\MyApp\platforms\android\gradlew cdvBuildDebug -b T:\Coding\MyApp\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.android.support:support-v13:23+.
 Searched in the following locations:
     https://repo1.maven.org/maven2/com/android/support/support-v13/maven-metadata.xml
     https://repo1.maven.org/maven2/com/android/support/support-v13/
     file:/C:/Users/itsme/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v13/maven-metadata.xml
     file:/C:/Users/itsme/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/support-v13/maven-metadata.xml
     file:/C:/Users/itsme/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/support-v13/
 Required by:
     :android:unspecified

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

BUILD FAILED

Total time: 22.476 secs

T:\Coding\MyApp\platforms\android\cordova\node_modules\q\q.js:126
            throw e;
                  ^
Error code 1 for command: cmd with args: /s /c "T:\Coding\MyApp\platforms\android\gradlew cdvBuildDebug -b T:\Coding\MyApp\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true"
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project

But why? How to resolve this little hurdle?

What plugins are you using?

This ones:

cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.0 "Device"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.4.0 "File Transfer"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-splashscreen 3.0.0 "Splashscreen"
cordova-plugin-sqlite 0.9.0 "Cordova Sqllite Plugine"
cordova-plugin-statusbar 2.0.0 "StatusBar"
cordova-plugin-whitelist 1.2.0 "Whitelist"
ionic-plugin-keyboard 1.0.8 "Keyboard"
phonegap-plugin-push 1.4.5 "PushPlugin"

Ionic 1.7.11
Cordova 5.4.1
Bower 1.6.8
npm 2.11.3

I would really be happy if anyone could give me a clue … :fish:

On the way I changed the plugin to https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git. This one seems to work very well.

I still would be happy to get a hint to the problem implementing phonegap-plugin-push.

Could not find any version that matches com.android.support:support-v13:23+.

If the plugin required a particular version of SDK, make sure you have that version of the SDK and support libraries installed.

(If it’s similar to a problem I had, try ionic platform add android@5.0.0, but my problem was with a different plugin (hence why i asked))

Open the file ‘build.gradle’ “{Project-Folder}/platforms/android/build.gradle”.

Change this :
dependencies {
compile fileTree(dir: ‘libs’, include: '.jar’) …}*

To:
dependencies {
compile fileTree(dir: ‘libs’, include: ‘gcm.jar’) …}

Now you should be able to build for android.

@sandips
It does not work.

After calling ionic build android I get this error:

...
:compileDebugJavaT:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:11: error: package com.almworks.sqlite4java does not exist
import com.almworks.sqlite4java.*;
^
T:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:365: error: cannot find symbol

  SQLiteConnection mydb;
  ^
  symbol:   class SQLiteConnection
  location: class SQLitePlugin.SQLiteDatabaseNDK
T:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:229: error: cannot find symbol
} catch (SQLiteException e) {
 ^
  symbol:   class SQLiteException
  location: class SQLitePlugin
T:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:374: error: cannot find symbol
mydb = new SQLiteConnection(dbFile);
   ^
  symbol:   class SQLiteConnection
  location: class SQLitePlugin.SQLiteDatabaseNDK
T:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:486: error: cannot find symbol
SQLiteStatement myStatement = mydb.prepare(query);
^
  symbol:   class SQLiteStatement
  location: class SQLitePlugin.SQLiteDatabaseNDK
T:\Coding\MyApp\platforms\android\src\io\liteglue\SQLitePlugin.java:531: error: strings in switch are not supported in -source 1.6
switch (myStatement.columnType(i)) {
                              ^
  (use -source 7 or higher to enable strings in switch)
Note: Some input files use or override a deprecated API.
 FAILED
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJava'.
> Compilation failed; see the compiler error output for details.

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

BUILD FAILED

Total time: 47.79 secs

T:\Coding\MyApp\platforms\android\cordova\node_modules\q\q.js:126
            throw e;
                  ^
Error code 1 for command: cmd with args: /s /c "T:\Coding\MyApp\platforms\android\gradlew cdvBuildDebug -b T:\Coding\MyApp\platforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1

This issue is linked with SQLitePlugin. Please check your code.

But before adding phonegap-plugin-push it worked. So why this (first) error? Changing the build.gradle file caused this second error … So changing build.gradle causes an error in the sqlite-plugin? I don’t understand how.

Had the same issue.
You shouldn’t touch gradle file.
Just update/install:
a) Android Support Repository and Android Support Library
b) Google Repository and Google Play services

1 Like

a) Android Support Repository and Android Support Library
b) Google Repository and Google Play services

I am not shure … So I installed EVERYTHING from the Android SDK Manager. Did you mean that with a) and b)?

Yes, i installed it from SDK Manager.
First time I had the same mistake as you [quote=“HappyHappyJoyJoy, post:1, topic:38492”]
Could not find any version that matches com.android.support:support-v13:23+.
[/quote]
I installed 2 points Android Support Repository and Android Support Library.

Then I had another error (something about “play-services-gcm”). I installed Google Repository and Google Play services from SDK.

After that everything builds fine.
Don’t remember exactly, but it seems, I removed /platforms/andoid folder and then used “ionic platform add android” again in CLI.

2 Likes

I’m having the same issue with the same plugin.

Install the plugin cordova-android-support-v4 (from memory) directly, as android.support.v4 resolves to this npm name then bugs out when it finds the ID does not match - ironically, “android.support.v4”.

Make certain you have Google Play Services and also Support installed through the Android SDK manager.

Android plugins after 3.3.1-0.2.1 use Gradle. If you’re using PhoneGap prior to … a release in March, in think, then it’ll not have Gradle capabilities. The choice is then to upgrade PhoneGap, else manually grab each required jar files (from maven), and include one of the manual googleplay-support plugins from GitHub. There’s ones for versions 19, 21, 25 of this library, and I’ve put up one recently for v28.0.0 (current) a.k.a. 8.3.0.

Also make sure you install the stuff to the right folder, that’s what got me.