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

Solving version conflicts with project.ext no longer working in 3.3 #878

Closed
NickIliev opened this Issue Nov 9, 2017 · 12 comments

Comments

Projects
None yet
4 participants
@NickIliev
Copy link
Member

NickIliev commented Nov 9, 2017

From @hettiger on November 8, 2017 17:10

Issue

In {NS} 3.2 I did something like this in my app.gradle file to have nativescript-plugin-firebase work well together with nativescript-cardview, nativescript-geolocation and nativescript-google-maps-sdk plugins:

// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
//	compile 'com.android.support:recyclerview-v7:+'
//}

android {  
  defaultConfig {  
    generatedDensities = []
    applicationId = "org.nativescript.testns33"
    multiDexEnabled = true
  }  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }
  project.ext {
    googlePlayServicesVersion = "11.2.2"
    supportVersion = "26.0.0"
  }
}

def settingsGradlePath = "$projectDir/../../app/App_Resources/Android/settings.gradle";
def settingsGradleFile = new File(settingsGradlePath);
if(settingsGradleFile.exists())
{
    apply from: settingsGradleFile;
}

Unfortunately this no longer works with {NS} 3.3 because the following part no longer gets respected:

  project.ext {
    googlePlayServicesVersion = "11.2.2"
    supportVersion = "26.0.0"
  }

Proof

If you put something like this into the node_modules/..../nativescript-geolocation/.../include.gradle

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
	productFlavors {
		"nativescript-geolocation" {
			dimension "nativescript-geolocation"
		}
	}
}

dependencies {
	def googlePlayServicesVersion = project.ext.googlePlayServicesVersion
	compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
}

You get an error like this:

FAILURE: Build failed with an exception.

* Where:
Script '~/test-ns-33/platforms/android/build/configurations/nativescript-geolocation/include.gradle' line: 19

* What went wrong:
A problem occurred evaluating script.
> Cannot get property 'googlePlayServicesVersion' on extra properties extension as it does not exist

Copied from original issue: NativeScript/NativeScript#5049

@NickIliev NickIliev self-assigned this Nov 9, 2017

@NickIliev

This comment has been minimized.

Copy link
Member Author

NickIliev commented Nov 9, 2017

@hettiger confirming this as a bug with the latest Android runtime (3.3.0).
The issue is not reproducible with tns-android 3.2.0

Steps to reproduce:

  • create sample project tns create issue5043 --tsc
  • add a plugin that uses Google Play Services
tns plugin add nativescript-geolocation
  • in the application app.gradle add googlePlayServicesVersion
project.ext {
    googlePlayServicesVersion = "11.2.2"
  }
  • in the plugin include.gradle use the propery
dependencies {
	def googlePlayServicesVersion = project.googlePlayServicesVersion
	compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
}
@petekanev

This comment has been minimized.

Copy link
Contributor

petekanev commented Nov 9, 2017

Hey @hettiger, the user configurations which provides the global property for other plugins to interpolate from is applied after all the other configurations. This mechanism allows the user configuration to take precedence and override any other gradle rules the user would decide.

We'll let you know when the problem has been addressed.

@hettiger

This comment has been minimized.

Copy link

hettiger commented Nov 9, 2017

Thank you for the update @Pip3r4o

I can imagine it breaks a lot of apps that people try to update and it's really hard for non native devs to figure out what's going on thought. Maybe there should be a notice on https://docs.nativescript.org/releases/breaking-changes until this has been fixed?

@petekanev

This comment has been minimized.

Copy link
Contributor

petekanev commented Nov 9, 2017

@hettiger the issue has been addressed.

Please give the fix a try by executing tns platform add android@rc which should fetch the pre-release of today's hotfix 3.3.1

Expect a patch release (3.3.1) of the android runtime later today

@hettiger

This comment has been minimized.

Copy link

hettiger commented Nov 9, 2017

@Pip3r4o Thank you for the hotfix. I've successfully built with 3.3.1 removing the following part from my app.gradle file:

def settingsGradlePath = "$projectDir/../../app/App_Resources/Android/settings.gradle";
def settingsGradleFile = new File(settingsGradlePath);
if(settingsGradleFile.exists())
{
    apply from: settingsGradleFile;
}

NativeScript Sidekick adds these lines automatically to my app.gradle file.

Conclusion

  • The hotfix solves the initial problem
  • The hotfix introduces incompatibility with NativeScript Sidekick
@petekanev

This comment has been minimized.

Copy link
Contributor

petekanev commented Nov 9, 2017

@hettiger I've not tried the changes with Sidekick, I'll test further with Sidekick before pushing the patch release to ensure there are no incompatibilities.

@hettiger

This comment has been minimized.

Copy link

hettiger commented Nov 9, 2017

@Pip3r4o That's great news, thank you. If you want me to test it again let me know once another RC is available.

@petekanev

This comment has been minimized.

Copy link
Contributor

petekanev commented Nov 9, 2017

@hettiger we reverted the app.gradle application logic altogether to match the pre-3.3.0 behavior. Please give the android@rc another try. Thank you!

@hettiger

This comment has been minimized.

Copy link

hettiger commented Nov 9, 2017

@Pip3r4o awesome, I can now confirm that it is working with or without the additions from Sidekick. Thank you, looking forward to be installing the patch 👍

@petekanev

This comment has been minimized.

Copy link
Contributor

petekanev commented Nov 13, 2017

Problem addressed in the 3.3.1 release of NativeScript.

@AnthonySmith01

This comment has been minimized.

Copy link

AnthonySmith01 commented Nov 28, 2017

Hi @Pip3r4o , thanks for the great work on this.

Although I received a new error when using android@rc, any ideas?

Error: Failed to crunch file C:\project\platforms\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\11.6.2\res\drawable-hdpi-v4\common_google_signin_btn_icon_dark_normal_background.9.png into C:\project\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-hdpi-v4\common_google_signin_btn_icon_dark_normal_background.9.png

@AnthonySmith01

This comment has been minimized.

Copy link

AnthonySmith01 commented Nov 28, 2017

Ah found my own solution just then, looks like the window path was too long. Here is a link for anyone else: #803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment