Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on android (w/ pushbots plugin) #94

Closed
optikalefx opened this issue Apr 5, 2016 · 20 comments
Closed

Fails to build on android (w/ pushbots plugin) #94

optikalefx opened this issue Apr 5, 2016 · 20 comments

Comments

@optikalefx
Copy link

Ref pushbots/phonegap#33

@renesansz
Copy link
Contributor

@optikalefx
I'll try to look at this problem, currently I don't have any test apps to try out the reported issue.

@optikalefx
Copy link
Author

ok, ill try to give you any more info I find as I dive into this as well

@optikalefx
Copy link
Author

The last known working date on this was feb 23rd

@optikalefx
Copy link
Author

Checking out both coded bases around that date allows it to work. (and of course changing the interface for branch to allow running this back then)

@optikalefx
Copy link
Author

pushbots plugin does not have to be set back on the 23rd. So the latest pushbots with #81d4aed7f0d0a5f32226cfc0b0fc20b4a0c500da of branch works.

@optikalefx
Copy link
Author

OK, got the commit.

This works
9cfe039

This fails
bff6c97

So bff6c97 broke the build when combined with pushbots.

@renesansz
Copy link
Contributor

Thanks for the info @optikalefx ,
I'll try to look at the commits to see which causes the issue with pushbot.

@renesansz
Copy link
Contributor

So far, the difference with the commits are only the iOS changes..
I would like to know the version of the plugin you're using?

@optikalefx
Copy link
Author

I'm using Pushbots on https://github.com/pushbots/phonegap/tree/master and branch on the commit one mentioned above.

Side note - It's possible that iOS changes can affect an android build. wkWebView used to mess that up to the point that I had to have that iOS specific plugin commented one when building for android.

@renesansz
Copy link
Contributor

@optikalefx,
I see, I wasn't aware of such problem. However, could you try using the latest branch.io plugin?
There might be problems with these and might be fixed in the future commits.

@optikalefx
Copy link
Author

So starting with bff6c97 all the way up to the latest it throws the same cordova build errors found here pushbots/phonegap#33

I can paste more examples but it's always the same build error.

* What went wrong:
Execution failed for task ':transformClassesWithDexForArmv7Debug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Slightly different if I build without crosswalk, but similar error.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> 
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

These are both built with the latest versions of both plugins.

@renesansz
Copy link
Contributor

@optikalefx ,
I see, this is weird, I'm trying to replicate the issue but I'm having hard time to duplicate one..

At the moment, can you re-build your app by doing the following:

  1. Remove all platforms (Simply remove the platforms directory)
  2. Remove all plugins (Simply remove the plugins directory)
  3. Re-install your platforms (cordova platform add <android/ios>)
  4. Re-install your plugins (cordova plugin add <plugin-here>)
  5. Build your app (phonegap build <android/ios>)
  6. Run the app

I'll give you an update once I've made any progress on replicating the issue.

@renesansz
Copy link
Contributor

@optikalefx ,
Okay, so I was able to replicate the error now, so after some reading.
I bump in to some Android related issues, and was able to fix mine.
Here are possible solutions:

  • In your build.gradle file add multiDexEnabled true inside your defaultConfig
defaultConfig {
    multiDexEnabled true
}
  • Remove the android-support-v4.jar in your Android libs directory.
  • Execute ./gradlew clean in the Android directory

References:

Let me know if this fixes the issue.

@optikalefx
Copy link
Author

So this does fix it, do you know if there is a way to do this from the plugin perspective? Having to do this on every build is obviously a pain. Also I have a build step so I'd need to add this file manipulation in there at some point if the plugin can't add this.

Maybe you have an option to add multiDex from your end?

@renesansz
Copy link
Contributor

Hey @optikalefx , Glad to hear that the fix works for you.
I'll try to find a much more convenient solution to automate the fix for this kind of issue.

At the moment, you can only modify the AndroidManifest.xml on a plugin. Not sure if it's possible to modify other files than that.

@optikalefx
Copy link
Author

The only way I know to do this otherwise is to create a pre-build hook sh file that does string regex. Not the most ideal for sure. Looking forward to seeing what you find

@renesansz
Copy link
Contributor

I see, I'll try to look at it if its doable. I'll let you know if I'm able to automate it.

Cheers,
Rene

@optikalefx
Copy link
Author

I found an automatic way in my grunt-phonegap setup. Using shell js inside of a before-build file.

in _phonegap.xml

<platform name="android">
    <allow-intent href="market:*" />
    <hook type="before_build" src="../lib/before-build.android.js" />
</platform>

inside of the before build file

// deep
var gradleFile = 'platforms/android/build.gradle';
shell.sed('-i', 'defaultConfig {', 'defaultConfig {\n\t\t\t\tmultiDexEnabled true', gradleFile);
shell.rm('platforms/android/libs/android-support-v4.jar');
shell.exec('cd platforms/android && ./gradle clean');

@renesansz
Copy link
Contributor

@optikalefx ,
Thanks for the build hook, however I can't assure that this would be merged from the master as we don't know if there will be other plugins that will be using the android-support-v4.jar.

Closing the issue now.

Cheers,
Rene

@optikalefx
Copy link
Author

yea I don't thinks should be included for you, but at least this ticket is here for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants