mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
fix: crash at application launch on Android P (#5831)
* fix: crash at application launch on Android P Reference: https://developer.android.com/preview/restrictions-non-sdk-interfaces Android P introduces new restrictions on the use of non-SDK interfaces, whether directly, via reflection, or via JNI. These restrictions are applied whenever an app references a non-SDK interface or attempts to obtain its handle using reflection or JNI. In particular, remove reflection via Class.getDeclaredField() and fallback default transition to fade transition. * refactor: create default transition based on SDK version Create default transition and setup default animations based on SDK version. This is to avoid reflection via Class.getDeclaredMethod() for Android P where it throws. * refactor: extract isAndroidP method
This commit is contained in:
@ -50,6 +50,10 @@ const sdkVersion = lazy(() => parseInt(device.sdkVersion));
|
|||||||
const intEvaluator = lazy(() => new android.animation.IntEvaluator());
|
const intEvaluator = lazy(() => new android.animation.IntEvaluator());
|
||||||
const defaultInterpolator = lazy(() => new android.view.animation.AccelerateDecelerateInterpolator());
|
const defaultInterpolator = lazy(() => new android.view.animation.AccelerateDecelerateInterpolator());
|
||||||
|
|
||||||
|
// NOTE: Android P Beta SDK version returns 27, which is API level for Android 8.1
|
||||||
|
// TODO: Update condition when Android P SDK version returns 28
|
||||||
|
const isAndroidP = lazy(() => sdkVersion() >= 27);
|
||||||
|
|
||||||
export const waitingQueue = new Map<number, Set<ExpandedEntry>>();
|
export const waitingQueue = new Map<number, Set<ExpandedEntry>>();
|
||||||
export const completedEntries = new Map<number, ExpandedEntry>();
|
export const completedEntries = new Map<number, ExpandedEntry>();
|
||||||
|
|
||||||
@ -76,7 +80,9 @@ export function _setAndroidFragmentTransitions(
|
|||||||
throw new Error("Calling navigation before previous navigation finish.");
|
throw new Error("Calling navigation before previous navigation finish.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isAndroidP()) {
|
||||||
initDefaultAnimations(manager);
|
initDefaultAnimations(manager);
|
||||||
|
}
|
||||||
|
|
||||||
if (sdkVersion() >= 21) {
|
if (sdkVersion() >= 21) {
|
||||||
allowTransitionOverlap(currentFragment);
|
allowTransitionOverlap(currentFragment);
|
||||||
@ -116,7 +122,11 @@ export function _setAndroidFragmentTransitions(
|
|||||||
if (name === "none") {
|
if (name === "none") {
|
||||||
transition = new NoTransition(0, null);
|
transition = new NoTransition(0, null);
|
||||||
} else if (name === "default") {
|
} else if (name === "default") {
|
||||||
|
if (isAndroidP()) {
|
||||||
|
transition = new FadeTransition(150, null);
|
||||||
|
} else {
|
||||||
transition = new DefaultTransition(0, null);
|
transition = new DefaultTransition(0, null);
|
||||||
|
}
|
||||||
} else if (useLollipopTransition) {
|
} else if (useLollipopTransition) {
|
||||||
// setEnterTransition: Enter
|
// setEnterTransition: Enter
|
||||||
// setExitTransition: Exit
|
// setExitTransition: Exit
|
||||||
@ -170,7 +180,11 @@ export function _setAndroidFragmentTransitions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isAndroidP()) {
|
||||||
|
setupDefaultAnimations(newEntry, new FadeTransition(150, null));
|
||||||
|
} else {
|
||||||
setupDefaultAnimations(newEntry, new DefaultTransition(0, null));
|
setupDefaultAnimations(newEntry, new DefaultTransition(0, null));
|
||||||
|
}
|
||||||
|
|
||||||
printTransitions(currentEntry);
|
printTransitions(currentEntry);
|
||||||
printTransitions(newEntry);
|
printTransitions(newEntry);
|
||||||
|
Reference in New Issue
Block a user