Open MBach opened 5 years ago
Have you tried an earlier release? There was a recent change to the Android build you might be hitting up against.
Release 0.3.9 was working fine.
I have made a complete clean but it didn't work as excepted (removed node_modules, Android build folders, etc.)
If 0.3.9 is working then I'd suggest you take a look at the release notes for 0.3.10 and the PR which introduced the change to 0.3.10 #80. As I've said in the past my android knowledge is fairly sparse. It's possible #80 introduced a breaking change and I should have bumped the version to 0.4, but that wasn't immediately obvious to me. Anyway take a look at #80 and see if upgrading your react build tools helps.
@MBach ping. Any luck figuring out what was happening here?
I think something like this should do the trick:
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 25)
buildToolsVersion safeExtGet('buildToolsVersion', "25.0.2")
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 25)
}
}
dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
}
With this, the release build was OK!
@MBach thanks for the update. We've been down this road before in #73, but the efforts stalled when I asked for some protections in the safeExtGet
method to ensure the project's current compileSdkVersion
and minSdkVersion
don't drop below the required version for the project. Mostly to save the consumers of this library from trying to use this in a project that doesn't support application shortcuts. This might be a misapplied place to enforce that check. I'm not sure how dependencies are resolved in the Android build process.
So it's not really a problem IMO. Fix the minSdkVersion
to 21 and you're good to go! Right now, I don't think anyone is using a compileSdkVersion
lower than 25.
Is this something you’d be willing to cook up? Or do you think #73 is close to what you’d do and I should just resurrect that and merge it in? Leaning pretty heavily on your experience here as again I’m feeling around in the dark.
If I remember correctly, dynamic shortcuts are working only with SDK 25 (Android 7.1), so it's kind of strange to have a minSdkVersion
at 21. There is no reason to upgrade the lower bound to 21 instead of 16.
Also, you are using @TargetApi
which is an old way to do it.
I think the Android implementation could be refactored by using @RequireApi
and wrapping the bridge with a classic if statement, and deporting the code into a private function:
@ReactMethod
public void setShortcutItems(ReadableArray items) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
setDynamicShortcuts(args);
}
}
and
@RequiresApi(Build.VERSION_CODES.N_MR1)
private void setDynamicShortcuts(args) {
///
}
The idea behind this is to be able to compile and execute the code everywhere, even on very old devices, but it won't do anything.
Finally, yes, PR#73 is close to what I've done.
Hi,
Using
"react-native-quick-actions": "0.3.10"
I can't build my App any more!