bytepark / auto_orientation Goto Github PK
View Code? Open in Web Editor NEWA flutter plugin to programmatically change the orientation and rotate
License: MIT License
A flutter plugin to programmatically change the orientation and rotate
License: MIT License
*** First throw call stack:
(
0 CoreFoundation 0x000000010aa206fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000109d14ac5 objc_exception_throw + 48
2 CoreFoundation 0x000000010aa20555 +[NSException raise:format:] + 197
3 UIKitCore 0x0000000115e48647 -[UIViewController __supportedInterfaceOrientations] + 921
4 UIKitCore 0x0000000115e37ee5 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 90
5 UIKitCore 0x000000011646c851 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 407
6 CoreFoundation 0x000000010a9625ec _CFNOTIFICATIONCENTER_IS<…>
This error is thrown very often on orientation change.
PlatformException(error, Attempt to invoke virtual method 'void android.app.Activity.setRequestedOrientation(int)' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.setRequestedOrientation(int)' on a null object reference
at de.bytepark.autoorientation.AutoOrientationPlugin.onMethodCall(AutoOrientationPlugin.java:50)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loop(Looper.java:206)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Running
minSDK = 21
targetSDK and compileSDK = 30
After installing this package my build generates the following two warnings:
/Users/jbmathes/flutter/.pub-cache/hosted/pub.dartlang.org/auto_orientation-2.0.2/android/src/main/java/de/bytepark/autoorientation/AutoOrientationPlugin.java:11: warning: [deprecation] Registrar in PluginRegistry has been deprecated import io.flutter.plugin.common.PluginRegistry.Registrar; ^ /Users/jbmathes/flutter/.pub-cache/hosted/pub.dartlang.org/auto_orientation-2.0.2/android/src/main/java/de/bytepark/autoorientation/AutoOrientationPlugin.java:18: warning: [deprecation] Registrar in PluginRegistry has been deprecated public static void registerWith(Registrar registrar) { ^ 2 warnings
There is currently no way to upgrade my flutter pub in order to upgrade this transitive dependency.
this plugin does nothing in iPad. i have tested it and got no result.
version:
auto_orientation: ^2.3.1
dyld: Symbol not found: ___chkstk_darwin
Referenced from: /private/var/containers/Bundle/Application/98E5EF61-DFDD-4CA4-91B0-F87A801EF774/xxxx.app/Frameworks/auto_orientation.framework/auto_orientation (which was built for iOS 13.0)
Expected in: /usr/lib/libSystem.B.dylib
in /private/var/containers/Bundle/Application/98E5EF61-DFDD-4CA4-91B0-F87A801EF774/xxxx.app/Frameworks/auto_orientation.framework/auto_orientation
Message from debugger: Terminated due to signal 9
the new version does not work well at ios15
try {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
AutoOrientation.landscapeRightMode();
} catch (e) {
showErrorSnackBar(e.toString());
}
when i use this plugin in ipad, this not effective
Steps to reproduce:
I have opened a pull request that resolves this issue. Let me know if you have any questions.
Hi, I tried to use this package like so:
await AutoOrientation.landscapeLeftMode();
This works fine on iOS but hangs on Android. I'm actually supposed to not await
the result, even though the function returns a Future, which confused me.
The implementation of onMethodCall
…
should probably end with a result.success(null);
to prevent this possible confusion.
I tested it on an iPad (iOS 12.3.1) and it had no effect. Not in my app and not with the example app.
Screen rotation is allowed in iOS.
Here a screen recording of the example app: https://streamable.com/vve0p
Hi,
Can you please migrate the libraries to android-x and also update the gradle version.
thanks
I run the example app on a Iphone 11 which is on 16.4.1 and it's not working, the screen doesn't get locked.
Also, I run on a iPhone 6s Plus (iOS 15) and it's working perfectly.
Edit: auto_orientation 2.3.1
auto_orientation: ^1.0.5
flutter:1.7.8-hotfix4
await AutoOrientation.landscapeRightMode();
static landscapeRightMode() async {
// delete below line
// SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight]);
try {
await _channel.invokeMethod('setLandscapeRight');
} on MissingPluginException catch (_) {
return;
}
}
I'm testing on iOS 15+ & when I am in my landscape view if fullAutoMode
is triggered it pops me back to Portrait. It does not do this on Android.
Hi,
After upgrading Flutter to version 1.12, I have a problem when I try to build the Android apk with this plugin.
I'm using auto_orientation 1.0.5 (but the problem also happens with previous versions)
So, if I execute this in the terminal:
flutter build apk -t lib/main.dart
The answer is:
FAILURE: Build failed with an exception.
_
What went wrong:
Execution failed for task ':auto_orientation:verifyReleaseResources'.
_
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
/Users/myusername/.gradle/caches/transforms-2/files-2.1/770ea370d069fd246bf26e2a436ee35e/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
_
/Users/myusername/.gradle/caches/transforms-2/files-2.1/770ea370d069fd246bf26e2a436ee35e/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
If I remove 'auto_orientation' from the pubspec.yaml file, the build works fine. I use other plugins, and this is the only one that has this type of problem. This error doesn't happen in previous versions of Flutter.
My flutter doctor:
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale es-ES)
• Flutter version 1.12.13+hotfix.5 at /Users/pabloinsua/Programas/flutter
• Framework revision 27321ebbad (hace 34 horas), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
_
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/pabloinsua/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
_
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.3
_
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
_
[✓] IntelliJ IDEA Community Edition (version 2018.3.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 31.3.4
• Dart plugin version 183.5153.38
_
[✓] VS Code (version 1.40.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0
[!] CocoaPods could not find compatible versions for pod "auto_orientation":
In Podfile:
auto_orientation (from `.symlinks/plugins/auto_orientation/ios`)
Specs satisfying the `auto_orientation (from `.symlinks/plugins/auto_orientation/ios`)` dependency were found, but they required a higher minimum deployment target.
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
await AutoOrientation
.portraitUpMode();
After execution, the phone does not lock the direction, but the screen direction cannot be automatically rotated
I saw your comment about "portraitDownMode() (might not work)" in README.md and can confirm that this was my experience too. I'm not an Android developer, but I suspect this page captures the root cause:
https://stackoverflow.com/questions/41174723/android-sensorportrait-orientation-not-working
Their workaround defines an activity that can be extended to handle portrait and reversePortrait events, but I can't figure out how to work it into AutoOrientationPlugin.java. Do you have any advice? Thanks!
Flutter iOS backend switches back to portrait screen after switching to foreground mode
Would be wonderful for this plugin to be migrated to the V2 embedding.
The plugin
auto_orientation
is built using an older version of the Android plugin API which assumes that it's running in a full-Flutter environment. It may have undefined behaviors when Flutter is integrated into an existing app as a module.
The plugin can be updated to the v2 Android Plugin APIs by following https://flutter.dev/go/android-plugin-migration.
i found this error when i upgrading my build:gradle to 8.1.2 version
A problem occurred configuring project ':auto_orientation'.
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl.getNamespace(VariantDslInfoImpl.kt:77)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl.initApplicationId(VariantDslInfoImpl.kt:125)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl.access$initApplicationId(VariantDslInfoImpl.kt:37)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl$applicationId$2.invoke(VariantDslInfoImpl.kt:91)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl$applicationId$2.invoke(VariantDslInfoImpl.kt:88)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl.getApplicationId(VariantDslInfoImpl.kt:88)
at com.android.build.gradle.internal.core.dsl.impl.ComponentDslInfoImpl$mergedFlavor$2.invoke(ComponentDslInfoImpl.kt:67)
at com.android.build.gradle.internal.core.dsl.impl.ComponentDslInfoImpl$mergedFlavor$2.invoke(ComponentDslInfoImpl.kt:63)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.android.build.gradle.internal.core.dsl.impl.ComponentDslInfoImpl.getMergedFlavor(ComponentDslInfoImpl.kt:63)
at com.android.build.gradle.internal.core.dsl.impl.VariantDslInfoImpl.getMinSdkVersion(VariantDslInfoImpl.kt:63)
at com.android.build.api.variant.impl.VariantBuilderImpl.(VariantBuilderImpl.kt:48)
at com.android.build.api.variant.impl.LibraryVariantBuilderImpl.(LibraryVariantBuilderImpl.kt:35)
at com.android.build.api.variant.impl.LibraryVariantBuilderImpl_Decorated.(Unknown Source)
at jdk.internal.reflect.GeneratedConstructorAccessor137.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at org.gradle.internal.instantiation.generator.AsmBackedClassGenerator$InvokeConstructorStrategy.newInstance(AsmBackedClassGenerator.java:1948)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator$GeneratedClassImpl$GeneratedConstructorImpl.lambda$newInstance$0(AbstractClassGenerator.java:510)
at org.gradle.internal.deprecation.DeprecationLogger$4.create(DeprecationLogger.java:295)
at org.gradle.internal.deprecation.DeprecationLogger.whileDisabledThrowing(DeprecationLogger.java:273)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator$GeneratedClassImpl$GeneratedConstructorImpl.newInstance(AbstractClassGenerator.java:509)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:64)
... 211 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.