【问题标题】:“IllegalStateException: Only fullscreen activities can request orientation“IllegalStateException:只有全屏活动可以请求方向
【发布时间】:2018-07-07 07:18:24
【问题描述】:

我很想将 Glide 库从 3.8.0 更新到 4.5.0 但我在 recyclerview 遇到这个问题时我将com.github.bumptech.glide:glide:4.5.0 添加到我的Build.Gradle 文件中我在recyclerview 编译行中收到此错误。

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:support-compat:27.0.2 and com.android.support:animated-vector-drawable:26.1.0.

我决定将 targetSdkVersion 从 26 更新到 27,它可以工作,但是当我在 android 26 的设备中运行我的应用程序时,我遇到了这个错误并且应用程序崩溃

 java.lang.IllegalStateException: Only fullscreen activities can request orientation
                                                      at com.android.server.am.ActivityRecord.setRequestedOrientation(ActivityRecord.java:2189)

经过一番研究找到解决方案,SDK应该是26,但如果我这样做,我会再次回到同样的问题。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "maa.myapp"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 43
        versionName "4.1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}
android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}
dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //notifications
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.github.chrisbanes:PhotoView:2.1.3'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.github.bumptech.glide:glide:4.5.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.firebase:firebase-jobdispatcher:0.6.0'
    compile 'com.vodyasov:amr:0.5'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
    compile 'com.google.guava:guava:23.6-android'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup:otto:1.3.8'
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

    标签: android ads android-glide recyclerview-layout target-sdk


    【解决方案1】:

    我遇到了类似的问题。我看到两个选项。第一个是带有 Android O 的控制设备(这个 android 有错误“只有全屏活动可以请求方向”)并验证您是否可以更改它们的行为,或者找到使用相同支持库版本的 glide 版本。如果您在 android O 上的问题与 AdMob 有关,您可以查看this link

    【讨论】:

      【解决方案2】:

      这是 Android 版本 8.0 (API 26) 的问题

      我使用以下方法解决了 在清单中添加此代码

        <activity
                  android:name="com.google.android.gms.ads.AdActivity"
                  android:theme="@style/AppTheme"
                  tools:replace="android:theme"
                  />
      

      在 res/styles 中 添加以下代码

       <!-- Base application theme. -->
          <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
              <!-- Customize your theme here. -->
              <item name="alertDialogTheme">@style/StyledDialog1</item>
              <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
              <item name="android:windowNoTitle">true</item>
              <item name="windowActionBar">false</item>
              <item name="colorPrimary">@color/primary1</item>
              <item name="colorPrimaryDark">@color/primary1</item>
              <item name="colorAccent">@color/accent1</item>
              <item name="android:actionMenuTextColor">@color/fbutton_color_pomegranate</item>
      
              <item name="android:textColor">@color/primary_text</item>
              <item name="android:textColorSecondary">@color/secondary_text</item>
              <item name="android:textColorPrimary">@color/primary_text</item>
      
              <item name="android:popupMenuStyle">@style/popupMenuStyle</item>
          </style>
      

      注意:在 res/style apptheme 中,如果您不使用任何项目,请删除项目

      如果对你们有帮助,请告诉我!快乐编码

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-10
        • 1970-01-01
        • 2018-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多