-
Notifications
You must be signed in to change notification settings - Fork 1.9k
cordova run android not working #1718
Comments
@giladKaplan I don't think the problem is coming from this plugin. It is probably another plugin that is using the |
@giladKaplan Could you post your list of installed cordova plugins and the content of the file |
XXXXXX-push.gradle `import java.util.regex.Pattern def doExtractStringFromManifest(name) { cdvPluginPostBuildExtras << { android {
} List of plugins "cordova-custom-config": {}, |
@giladKaplan try building without cordova-plugin-google-analytics |
I have the same issue :( |
I opened up the generated android platform up in Android Studio and I was able to get the build further along. Basically some plugins add dependencies for play services e.g. googleplus. During the build
Cordova does some regex voodoo and changes mapped library numbers so even if you force a version it still uses the +.
Whenever you run cordova build it will do the regex and replace a custom version number. E.g. 9.2.1 so that will break it. But I went in android studio and manually changed the numbers and did an android gradle build (without cordova build magic)
Now I am getting an error Error:Execution failed for task ':transformClassesWithDexForDebug'.
So the issues is it is a version conflict I belive as well as a cordova problem without being able to force a version number YAY! 👎 Hope this helps. We may need to see if there is a way for cordova (issue request) to not do this if a config value is manually set. IDK |
Ok I set it to match the firebase messaging lib and it worked and built in android studio. build.gradle
|
Example of plugin that uses libraries |
Ok so I got it to work with cordova build. I edited the other plugins (googleplus) plugin.xml and changed it to use a specific version that was compatible.
I deleted the android platform and rebuilt. Which was funny, because I upgraded to the version that used cocoapods to avoid issues with duplicate symbols on IOS, but then it broke Android lol 😹 |
Here is a hacky 🔧 way to fix it temporarily so it will run and be fixed, basically create a custom cordova hook. https://gist.github.com/ianlintner-wf/9b042900cd70b518b506fb989d7085c0 Put this hook in your config with the filename. This may not fix your situation, but my limited knowledge of the cordova build process and gradle I managed to hack my way through the issue in cordova/ionic. |
@ianlintner-wf thanks for looking into this. I'm going to talk to Joe today to see if we can get a true fix in cordova-android. |
Hmm...the root cause of this issue is that this line https://github.com/phonegap/phonegap-plugin-push/blob/v2.0.x/push.gradle#L12 should be applied after the dependencies are setup. Trying to figure out a way to make that happen. |
I did a little more digging. So the dependencies are not updated in the project.properties on build so if the plugins are updated I had to remove the platform android folder. There is probably good reason for this. (or in my case I didn't see it rebuilt) I wrote the above script so I didn't have to hack/fork the node_modules/problem plugins configs. I don't know off hand if the config.xml overrides plugins. But basically the crux of the issue is version conflict and gradle barfs when other plugins try to use '+' as a version with the different versions com.google.android.gms:play-services & com.google.gms.google-services The error message is not very descriptive and I have no gradle knowledge so I don't know why the '+' is an issue, but it is when other plugins use it and gets applied added to the project.properties for that library. |
@ianlintner-wf the hook didn't do it for me. Any other suggestions? Thanks |
I got around it by going to project.properties and changing But this needs a proper fix |
I don't using the analytics service and get the same error.
this is my project.properties
|
@performatric it's the cordova-plugin-firebase. You should use either cordova-plugin-firebase or phonegap-plugin-push as they don't coexist well. |
@performatric try changing to something like below then run the build:
|
I tried, but returns the same error =/ |
I fixed the issue doing: |
Based on another issue with GCM vs FCM, I needed to move to phonegap-plugin-push@2.0.0-rc5. Thus in order to do that I had to update my
Now, based on the above reading, I don't have plugin-firebase or plugin-analytics so I don't know what is causing this issue. How can I fix it? Here are my plugins: |
@rolinger Just to rule it out: can you confirm you have your Android SDK updated as needed? (see the docs for directions on this) |
hmmmm....I did all the automatic updates already. but when I look in my Android SDK Manager I see |
When you modify all those :+ there to 11.0.1, it will work. Your task is to discover those other plugins you’re using which are importing the version “:+” |
Awesome, thank you for clearing that up, and sorry about that. |
Yep I have a manual install step that when I remove and re-add the android platform I need to edit the |
Manually editing project.properties is a hack. You need to fix the problem properly by finding the offending plugin responsible for importing the incorrect version of play services and align it to the same version required by plugin-push. All plugins requiring play-services must align to the same version. |
Dependency hell in a nutshell, fellow developers. 😠 |
This “dependency” hell is the fault of Cordova, which doesn’t provide you access to a build.grade to have the final say on dependencies. They try to abstract all that away, leaving you powerless. These dependency clashes are far more easily solved in react-native. |
@christocracy in this case, the offending plugin is phonegap-plugin-push :) All my other GMS-consuming plugins use I haven't yet gotten around to trying with the flag. It should work if I just set |
I wouldn't use version |
@christocracy Right now that isn't an option for me. I have 5 different plugins that utilize GSM and all of them are set to + except for Push and none of them support FCM_VERSION or any similar mechanism. This means |
@codinronan You need to go talk to your other dependencies. The problem is not here. |
@codinronan Did you read my explanation here? |
@christocracy I didn't mean to suggest that this plugin is doing the wrong thing. It's the only one doing it right! I just meant it's the only one doing it differently. I still need an answer to my question for an interim solution. Trying to get the other plugin authors to fix their plugins RIGHT NOW!!!!111111qqqq isn't going to work. |
@codinronan I have no solution for you. I'm not associated with |
@christocracy ❤️ We're in the pits together! :) No worries. I'll give it a shot and see what happens.. |
@codinronan I'm no longer in the pits. I've implemented the same |
This is still an issue, I can get it working by manually setting versions in the .gradle file, however phonegapbuild is not working. It looks like they have added a feature to the next release (7.2.0). https://issues.apache.org/jira/browse/CB-13145 Adding something like: |
@chadmilden I have a cordova prepare hook to fix this for now. This is not something that can be fixed at a single plugin level, it needs Cordova support. In the meantime, the script I use is documented here: https://gist.github.com/ianlintner-wf/9b042900cd70b518b506fb989d7085c0#gistcomment-2284764 And inside config.xml:
|
this looks like it's what I need, but I can't get the phonegapbuild site to execute the hook. it's uploading correctly, I tried a hook type of: before_prepare, after_prepare, inside I tested it out locally and it does work |
Just found this: Looks like PGB does not support custom hooks. So guess I'm waiting until 7.2.0. Thanks for the help. |
This problem is caused by a bug on GoogleServicesPlugin class. Gradle allows to use dynamic version dependencies like "+" or "9.+", meaning that it will use the latest version available matching the given expression. Looking at GoogleServicesPlugin class, there is some point where it reads all firebase dependencies versions and sorts them in order to do an internal check. To sort, it uses a SortedSet using this comparator: This method doesn't support + wildcards, it throws a java.lang.NumberFormatException: For input String '+' on this line: This problem is easy to solve: + character must be the highest 'number' in the version comparison. Maybe using something like this
Regards |
Hi, I have this in my project.properties target=android-26 And have this error
Someone have this error? |
@ianlintner-wf Is there any way to Hug you?
It worked for me! |
@degroundshaker You don't want to use You want to be using the latest available version, which is
You are exposing yourself to a world of issues when your app runs on different devices running other versions of Android OS than you're testing upon. |
This thread has been automatically locked. |
Expected Behaviour
I'm trying to do 'cordova run android'
Actual Behaviour
Error: /Users/giladkaplan1/Projects/Production/EPAActive/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
Where:
Script '/Users/giladkaplan1/Projects/Production/EPAActive/platforms/android/phonegap-plugin-push/XXXXXX-push.gradle' line: 12
What went wrong:
A problem occurred evaluating root project 'android'.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Cordova CLI version and cordova platform version
cordova : 6.5.0
ionic: 2.2.3
Plugin version
I'm using this version because i need FCM
cordova plugin version | grep phonegap-plugin-push phonegap-plugin-push 2.0.0-rc3 "PushPlugin"
Please help!!!! I'm stuck for 2 whole days on this error
thanks
The text was updated successfully, but these errors were encountered: