HipByte / Flow

Cross-platform libraries for RubyMotion
BSD 2-Clause "Simplified" License
141 stars 29 forks source link

Using with gradle - remove support-v4 from default? #43

Open rafaeliga opened 8 years ago

rafaeliga commented 8 years ago

Is there a way to remove android-support-v* from default config?

My project needs motion-gradle support and I want to keep everything there, using gradle.

These are the lines that I needed to remove from default android project file:

vendor_dir = File.join(File.dirname(__FILE__), '../vendor/android')
  v7_app_compat_dir = File.join(vendor_dir, 'support/v7/appcompat')
  app.vendor_project(:jar => File.join(v7_app_compat_dir, "/libs/android-support-v4.jar"))
  app.vendor_project(:jar => File.join(v7_app_compat_dir, "/libs/android-support-v7-appcompat.jar"), :resources => File.join(v7_app_compat_dir, "/res"), :manifest => File.join(v7_app_compat_dir, "/AndroidManifest.xml"))
  app.vendor_project(:jar => File.join(vendor_dir, 'google-play-services_lib/libs/google-play-services.jar'), :filter => ['^.com.google.android.gms.vision'], :resources => File.join(vendor_dir, 'google-play-services_lib/res'), :manifest => File.join(vendor_dir, 'google-play-services_lib/AndroidManifest.xml'))
  app.manifest_entry('application', 'meta-data', :name => 'com.google.android.gms.version', :value => '@integer/google_play_services_version')
  app.manifest_entry('application', 'meta-data', :name => 'com.google.android.gms.vision.DEPENDENCIES', :value => 'barcode')

I tried to find a way to just clean the vendor_projects array but it seems not possible with motion.

jjaffeux commented 8 years ago

The easy way would just be to use motion-gradle for Flow. We wanted Flow to be very easy to get started, so I would prefer not.

We could try to be smarter and detect if motion-gradle is in the project and if the gradle dependencies include support-v4, would be something like:

unless app.respond_to?(:gradle) && gradle.dependencies.map(&:name).include?("support-v4")
  vendor_dir = File.join(File.dirname(__FILE__), '../vendor/android')
  v7_app_compat_dir = File.join(vendor_dir, 'support/v7/appcompat')
  app.vendor_project(:jar => File.join(v7_app_compat_dir, "/libs/android-support-v4.jar"))
  app.vendor_project(:jar => File.join(v7_app_compat_dir, "/libs/android-support-v7-appcompat.jar"), :resources => File.join(v7_app_compat_dir, "/res"), :manifest => File.join(v7_app_compat_dir, "/AndroidManifest.xml"))
end
rafaeliga commented 8 years ago

That sounds good!

Thanks for your fast answer.

Do I need to create a pull request with this or will probably be include in a next release? :D

jjaffeux commented 8 years ago

happy to merge a PR if you get something working

rafaeliga commented 8 years ago

The first part works "unless app.respond_to?(:gradle)", but the second didnt, because on that moment my code that adds the gradle dependencies wasnt executed yet, is that right?

I can create a Pull request only with the respond_to, but Im sure if that is correct.

jjaffeux commented 8 years ago

yeah... was afraid of this, we need to figure out a solution to this :)

I don't have time to dig this for now, maybe using motion-gradle for flow would be the best solution.

rafaeliga commented 8 years ago

Got it.

Im going to create a pull request with that.

Thanks!