apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Unable to install the plugin geofence #790

Closed abdulkadhir closed 4 years ago

abdulkadhir commented 4 years ago

I'm unable to install the plugin. It gives the following errors Installing "cordova-plugin-geofence" for android Installing "cordova-plugin-add-swift-support" for android Android Studio project detected Installing "cordova-plugin-compat" for android Plugin doesn't support this project's cordova-android version. cordova-android: 7.1.4, failed version requirement: <6.3.0 Skipping 'cordova-plugin-compat' for android Installing "es6-promise-plugin" for android thanks in advance

janpio commented 4 years ago

This looks like a problem with the plugin, not Cordova Android. You should probably ask over there.

What version of the plugin are you installing? Why are you not using a current Cordova Android version?

breautek commented 4 years ago

There is also nothing here that suggest the plugin is actually failling to install.

Installing "cordova-plugin-compat" for android Plugin doesn't support this project's cordova-android version. cordova-android: 7.1.4, failed version requirement: <6.3.0 Skipping 'cordova-plugin-compat' for android

What this means that you have at least 1 plugin that depends on cordova-plugin-compat, but it is only necessary to have if you are using cordova-android < 6.3.0. Because you are using version 7.1.4, you don't need the cordova-plugin-compat library, therefore it just skips installing that plugin. The plugin that depends on this library should still work fine for as long as you're using cordova-android >= 6.3.0

abdulkadhir commented 4 years ago

There is also nothing here that suggest the plugin is actually failling to install.

Installing "cordova-plugin-compat" for android Plugin doesn't support this project's cordova-android version. cordova-android: 7.1.4, failed version requirement: <6.3.0 Skipping 'cordova-plugin-compat' for android

What this means that you have at least 1 plugin that depends on cordova-plugin-compat, but it is only necessary to have if you are using cordova-android < 6.3.0. Because you are using version 7.1.4, you don't need the cordova-plugin-compat library, therefore it just skips installing that plugin. The plugin that depends on this library should still work fine for as long as you're using cordova-android >= 6.3.0

But build is not happening.

breautek commented 4 years ago

You will need to provide us the full build output. What you have shown is not an error.

You may need to use --verbose flag to see details of an error.

cordova build android --verbose.

abdulkadhir commented 4 years ago

You will need to provide us the full build output. What you have shown is not an error.

You may need to use --verbose flag to see details of an error.

cordova build android --verbose.

after cordova build android --verbose it gives o scripts found for hook "before_build". No scripts found for hook "before_prepare". Checking config.xml and package.json for saved platforms that haven't been added to the project Config.xml and package.json platforms are the same. No pkg.json modification. Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms. PlatformApi successfully found for platform android Android Studio project detected Checking config.xml for saved plugins that haven't been added to the project Checking for any plugins added to the project that have not been installed in android platform No differences found between plugins added to project and installed in android platform. Continuing... Generating platform-specific config.xml from defaults for android at /Users/unique-creations/UC/gFence/platforms/android/app/src/main/res/xml/config.xml Merging project's config.xml into platform-specific android config.xml Merging and updating files from [www, platforms/android/platform_www] to platforms/android/app/src/main/assets/www Wrote out android application name "MyApp" to /Users/unique-creations/UC/gFence/platforms/android/app/src/main/res/values/strings.xml android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1 Wrote out Android package name "io.ionic.starter" to /Users/unique-creations/UC/gFence/platforms/android/app/src/main/java/io/ionic/starter/MainActivity.java Updating icons at platforms/android/app/src/main/res Updating splash screens at platforms/android/app/src/main/res This app does not have additional resource files defined Prepared android project successfully Executing script found in plugin cordova-plugin-add-swift-support for hook "after_prepare": plugins/cordova-plugin-add-swift-support/src/add-swift-support.js Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata Cannot find module '../cordova/platform_metadata' Error: Cannot find module '../cordova/platform_metadata' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.Module._load (internal/modules/cjs/loader.js:506:25) at Module.require (internal/modules/cjs/loader.js:636:17) at require (internal/modules/cjs/helpers.js:20:18) at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:88:12) at module.exports (/Users/unique-creations/UC/gFence/plugins/cordova-plugin-add-swift-support/src/add-swift-support.js:23:34) at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:196:18) at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:172:16) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:140:20 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:854:54)

breautek commented 4 years ago

Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata Cannot find module '../cordova/platform_metadata' Error: Cannot find module '../cordova/platform_metadata'

Is interesting, and is probably caused by using an older version of cordova-android and using (assumingly) more up to date cordova command line tools.

Like @janpio somewhat hinted earlier, if you can you should update cordova-android to the latest version if possible. The current release is 8.0.0.

cordova platform remove android
cordova platform add android@^8
abdulkadhir commented 4 years ago

cordova platform add android@^8 I tried but no luck it gives below error This app does not have additional resource files defined Prepared android project successfully Executing script found in plugin cordova-plugin-add-swift-support for hook "after_prepare": plugins/cordova-plugin-add-swift-support/src/add-swift-support.js Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata Cannot find module '../cordova/platform_metadata' Error: Cannot find module '../cordova/platform_metadata' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.Module._load (internal/modules/cjs/loader.js:506:25) at Module.require (internal/modules/cjs/loader.js:636:17) at require (internal/modules/cjs/helpers.js:20:18) at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:88:12) at module.exports (/Users/unique-creations/UC/gFence/plugins/cordova-plugin-add-swift-support/src/add-swift-support.js:23:34) at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:196:18) at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:172:16) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:140:20 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:854:54)

breautek commented 4 years ago

You'll need to give us your environment, preferably following the issue template that you would have deleted when creating this issue.

But in summary what we will need to know is:

abdulkadhir commented 4 years ago
  • cordova -v

8.1.2 (cordova-lib@8.1.1) node:v10.13.0

ionic info: cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.9.0
ionic (Ionic CLI) : 3.9.0

global packages:

Cordova CLI : 8.1.2 (cordova-lib@8.1.1) 

local packages:

@ionic/app-scripts : 3.2.4
Cordova Platforms  : android 8.0.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v10.13.0
npm               : 6.4.1 
OS                : macOS
Xcode             : Xcode 10.2.1 Build version 10E1001 
breautek commented 4 years ago

I apologize, I forgot to request the output of cordova plugin list as well.

abdulkadhir commented 4 years ago

cordova plugin list

cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-device 1.1.7 "Device" cordova-plugin-geofence 0.7.0 "geofence" cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview" cordova-plugin-splashscreen 4.1.0 "Splashscreen" cordova-plugin-whitelist 1.3.4 "Whitelist" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-keyboard 2.2.1 "Keyboard"

breautek commented 4 years ago

Ok I just created a test app and added cordova-plugin-geofence and cordova-plugin-add-swift-support and this is the error I received

Failed to install 'cordova-plugin-geofence': CordovaError: Version of installed plugin: "cordova-plugin-add-swift-support@2.0.2" does not satisfy dependency plugin requirement "cordova-plugin-add-swift-support@^1.6.0". Try --force to use installed plugin as dependency.

This means that cordova-plugin-geofence expects cordova-plugin-add-swift-support version 1.6 or higher, but not anything higher than 1.x

If you're seeing this error, that means you need to downgrade cordova-plugin-add-swift-support.

cordova plugin remove cordova-plugin-add-swift-support
cordova plugin add cordova-plugin-add-swift-support@^1.6.0
abdulkadhir commented 4 years ago

cordova plugin add cordova-plugin-add-swift-support@^1.6.0

FAILURE: Build failed with an exception.

BUILD FAILED in 2s at ChildProcess.whenDone (/Users/unique-creations/UC/gFence/node_modules/cordova-common/src/superspawn.js:135:23) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:962:16) at Socket.stream.socket.on (internal/child_process.js:381:11) at Socket.emit (events.js:182:13) at Pipe._handle.close (net.js:606:12)

but in my config.xml

minsdk value id 19

breautek commented 4 years ago

That means you have have a plugin that defines a min sdk 16 which conflicts with cordova's requirement of min sdk of at least 19.

Afraid to say but it now looks like you're starting to run into a rabbit hole of using out-dated/unmaintained plugins.

Aside from requesting the plugin maintainers to update their plugins there isn't a whole lot of good options you can do.

The last cordova-android version that used min-sdk 16 was version 6.x. You can try downgrading, but other things may break. You can also try forcing cordova to use min-sdk 16 (see cordova-android documentation) but that could cause runtime failures that might be hard to catch, so that isn't recommended either.

I took the liberty of adding all your plugins and forcing min-sdk to match, but it still does not build because of several native errors inside the cordova-plugin-geofence library. So you will either have to find a new geofence plugin that is up to date with maintenance, or you'll have to fork the library yourself and address the issues.

abdulkadhir commented 4 years ago

That means you have have a plugin that defines a min sdk 16 which conflicts with cordova's requirement of min sdk of at least 19.

Afraid to say but it now looks like you're starting to run into a rabbit hole of using out-dated/unmaintained plugins.

Aside from requesting the plugin maintainers to update their plugins there isn't a whole lot of good options you can do.

The last cordova-android version that used min-sdk 16 was version 6.x. You can try downgrading, but other things may break. You can also try forcing cordova to use min-sdk 16 (see cordova-android documentation) but that could cause runtime failures that might be hard to catch, so that isn't recommended either.

I took the liberty of adding all your plugins and forcing min-sdk to match, but it still does not build because of several native errors inside the cordova-plugin-geofence library. So you will either have to find a new geofence plugin that is up to date with maintenance, or you'll have to fork the library yourself and address the issues.

after solving minsdk issue now o got the following error fier.java:10: error: cannot find symbol import android.support.v4.app.NotificationCompat; ^ symbol: class NotificationCompat location: package android.support.v4.app /Users/unique-creations/UC/gFence/platforms/android/app/src/main/java/com/cowbell/cordova/geofence/GeoNotificationNotifier.java:11: error: cannot find symbol import android.support.v4.app.TaskStackBuilder;

breautek commented 4 years ago

This is one of the compilation issues I was referring to that comes from the geofence library. There isn't anything more that we can do at the cordova level.

You will need to raise an issue with the maintainers for the cordova-plugin-geofence plugin.

jcesarmobile commented 4 years ago

Closing as the bug is in the plugin and not in cordova-android

Fouziya-Banu commented 4 years ago

Hi, Any solution on this particular error from the maintainers of the plugin? Any link that I can refer to?

breautek commented 4 years ago

This is their repo. It looks like an abandoned project.

https://github.com/cowbell/cordova-plugin-geofence#readme