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

fix(android): 279 - Fix error cannot find symbol #281

Merged
merged 5 commits into from
Jul 3, 2021

Conversation

jdnichollsc
Copy link
Member

@jdnichollsc jdnichollsc commented Jul 3, 2021

Fix Build failed. Error cannot find symbol builder.setNavigationBarColor error for Android Support

PR Checklist

What is the current behavior?

Android Support is not working with the new methods of CustomTabsIntent.Builder for AndroidX.

What is the new behavior?

Detect if the method exists before to invoke the function to avoid build issues by using Reflection.

Fixes/Implements/Closes #279.

@reberthkss
Copy link
Collaborator

@jdnichollsc i think it should work, let me try it

@jdnichollsc
Copy link
Member Author

jdnichollsc commented Jul 3, 2021

@reberthkss awesome, let me know! <3

@jdnichollsc
Copy link
Member Author

Personally I don't like Reflection, but I can't see any other option 🤔

@reberthkss
Copy link
Collaborator

I've tested on my project and the error was gone, but I faced the same problem with create_react_context described in #279 (comment)

I'm trying to test in a bare react-native typescript template project

@jdnichollsc
Copy link
Member Author

Ohh very odd, please let me know! 🙏

@reberthkss
Copy link
Collaborator

Worked like a charm :3

2021-07-03.20-28-16.mp4

@@ -62,6 +63,26 @@
private Activity currentActivity;
private static final Pattern animationIdentifierPattern = Pattern.compile("^.+:.+/");

public Integer setColor(CustomTabsIntent.Builder builder, final ReadableMap options, String key, String method, String colorName) {
String colorString = "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be String colorString = options.getString(key);?

and further on try/catch block :

String colorString = options.getString(key);

...

try {
if (colorString != null) {
...
}

...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to validate if the key exist first, using options.hasKey(key)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reberthkss did you find another bug?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for known more, the response from getString function is Nullable, so if the key doesn't exist the colorString variable was null, alright? Why don't follow this approach? Is it a bad practice/insecure?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, this validation is old, if you want I can change it, no problem, thanks for noticing!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@jdnichollsc
Copy link
Member Author

@reberthkss nice! thanks for your help! 🤩

@jdnichollsc jdnichollsc merged commit bbb711d into develop Jul 3, 2021
@jdnichollsc jdnichollsc mentioned this pull request Jul 4, 2021
@pramahaditamaputra-ralali

The new release version 3.6.2 its works as well right Now in my app built with React Native version 0.61.5 , thanks for the fixing so i can use the lastest version of this library @jdnichollsc @reberthkss <3

@jdnichollsc jdnichollsc deleted the fix/error-cannot-find-symbol branch July 29, 2022 03:47
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

Successfully merging this pull request may close these issues.

Build failed. Error cannot find symbol builder.setNavigationBarColor
3 participants