안드로이드 스튜디오 3.6.
내 앱이 항상 portrait
모드 에 있기를 원합니다 . 그래서 내 AndroidMainfest.xml
:
<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
앱을 실행하고 모드로 SplashActivity
표시 portrait
합니다. 좋은. 그러나 편집기에는 다음 오류가 표시됩니다.
Expecting android:screenOrientation="unspecified"
왜?
답변
매니페스트 태그 (바로 아래 xmlns:android="http://schemas.android.com/apk/res/android"
)에
xmlns:tools="http://schemas.android.com/tools"
그런 다음 응용 프로그램 태그 안에
tools:ignore="LockedOrientationActivity"
답변
Android Studio 3.6 이상에만 영향을 미칩니다.
여기서 문제는 무엇입니까? 이 문제는 안드로이드 프레임 워크가 사용자가 앱 방향을 직접 제어하기를 원하기 때문에 발생합니다. 예를 들어 사용자가 가로 방향으로 앱을 사용하려는 경우 장치를 뒤집어 놓고 센서가 작동하지만 센서가 작동 할 때 개발자는 회전 센서가 작동하더라도 사용자의 기기 기능을 제한하는 방식으로 미리 정의 된 상태를 유지합니다.
지금 무엇을해야합니까? 두 가지 옵션이 있습니다. 첫 번째는 동일한 작업을 수행해도 빌드 실패가 발생하지 않으므로 오류를 무시하는 것이며 apk / aab 생성은 평소와 같습니다. 또 다른 옵션은 가로 레이아웃을 제공하거나 방향이 변경되면 인식하는 앱은 해당 방향에서 앱이 지원되지 않으므로 사용자에게 방향을 변경하라는 메시지를 표시합니다.
현재 => 현재 변경 될 수 있지만 빌드 프로세스에는 영향을 미치지 않지만 향후 변경 될 수 있습니다.
답변
Android Studio 3.6.0에서는 사용자가 방향을 처리하고 개발자가 ViewModel 을 사용하도록 권장하기를 바랍니다 . screenOrientation을 자세히 설명하겠습니다
android:screenOrientation="portrait"
당신은 당신이 지정 해야하는 오류를 줄 것이다
android:screenOrientation="fullSensor" or android:screenOrientation="unspecified"
fullSensor “회전 끄기”가 켜져 있거나 전화를 움직 인 방향에 따라 방향이 변경되지 않음을 의미합니다.
지정되지 않음 회전이 켜져 있으면 해당 방향으로 만 유지되고 그렇지 않은 경우 전화를 이동하는 방향에 따라 방향이 변경됩니다.
답변
tools:ignore="GoogleAppIndexingWarning,LockedOrientationActivity"
답변
아래 절차를 사용했습니다. 그것은 나를 위해 완벽하게 작동합니다. Android Studio 3.6.0에서는 사용자가 방향을 처리하고 개발자가 ViewModel을 사용하도록 권장하기를 원한다고 생각합니다. 이를 무시하려면 아래 절차를 사용하십시오.
먼저 추가 :
xmlns:android="http://schemas.android.com/apk/res/android"
매니페스트 태그에서.
둘째, 추가
tools:ignore="LockedOrientationActivity"
응용 프로그램 태그에. 행복한 코딩.
답변
이 문제를 해결하는 두 가지 방법을 찾았습니다.
먼저,
Android Studio -> Preferences (or settings in Windows)
-> search "chrome"
-> Uncheck "Activity is locked to an orientation"
-> apply and ok
-> Sync Project with Gradle flie
둘째,`
Select "Run" from the main menu
-> Edit Configurations.
-> Launch options - Launch
-> select Nothing or Specified Activity
-> Sync Project with Gradle file
답변
다음 줄 추가 android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity"
그런 다음 Alt+를 클릭하십시오Enter
