3

编辑 我删除了,Appodeal现在它可以工作了。没有它就没有构建,它已被弃用。我不确定问题出在哪里,但上述问题之一应该是问题所在。explorestack:consentjcenterAppodealjcenter

我最近更新了我build.gradle和 targetSdkVersion 中的库。在对其进行测试并上传到 Google Play 之后,我突然开始崩溃:

Fatal Exception: java.lang.IllegalArgumentException: com.name.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
       at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
       at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
       at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
       at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
       at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
       at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:920)

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.name.app/com.name.app.Activities.LoginActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class com.google.android.gms.common.SignInButton
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
       at android.app.ActivityThread.access$800(ActivityThread.java:156)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5314)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:374)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

我没有使用PendingIntent也许某些库呢?谷歌按钮以前从未出现过任何问题。

这里是build.gradles

应用程序:

apply plugin: 'com.android.application'
// Apply the Google Services plugin (if it's not there already).
apply plugin: 'com.google.gms.google-services'
// Add the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
android {
    signingConfigs {
        config {
            
        }
    }
    compileSdkVersion 31
    defaultConfig {
        applicationId "com.name.app"
        minSdkVersion 21
        targetSdkVersion 31

        versionCode 91
        versionName "91"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildToolsVersion "30.0.3"
}

repositories {
    maven { url "https://artifactory.appodeal.com/appodeal" }
    google()
    mavenCentral()
    jcenter()
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.media:media:1.4.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation 'com.google.android.material:material:1.5.0-alpha05'

    implementation 'androidx.activity:activity:1.4.0'

    implementation 'com.jjoe64:graphview:4.2.2'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-core:20.0.0'
    implementation 'com.google.firebase:firebase-database:20.0.2'
    implementation 'com.google.android.gms:play-services-auth:19.2.0'

    implementation 'com.android.billingclient:billing:4.0.0'
    implementation 'com.google.firebase:firebase-crashlytics:18.2.4'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    testImplementation 'junit:junit:4.13.2'
    implementation 'com.google.android.ump:user-messaging-platform:2.0.0'
    implementation 'com.google.code.gson:gson:2.8.6'

    implementation 'com.explorestack:consent:1.0.4'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'

    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation('com.appodeal.ads:sdk:2.10.2.+') {
        exclude group: 'com.appodeal.ads.sdk.networks', module: 'amazon_ads'
        exclude group: 'com.appodeal.ads.sdk.networks', module: 'appodeal'
        exclude group: 'com.appodeal.ads.sdk.networks', module: 'nast'
    }
}

项目:

buildscript {
    
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

有没有人经历过类似的事情?我无法重现它。

它崩溃了LoginActivity,这是开始活动。这是该AndroidManifest部分的内容:

<activity
    android:name=".LoginActivity"
    android:label="Name"
    android:exported="true"
    android:configChanges="orientation"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />

       <data
           android:scheme="http"
           android:host="name.com" />
    </intent-filter>
</activity>
4

5 回答 5

4

在您的第一个堆栈跟踪中,它表明工作管理器在尝试创建时崩溃PendingIntent

at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)

由于它在不同的线程上运行,因此看不到起源。我在我的项目中遇到了同样的问题,事实证明这是一个依赖于工作管理器库版本 < 的库2.7.02.7.0为 Android 12 准备的工作管理器库的第一个版本

在我的案例中,令人不安的依赖'com.google.android.gms:play-services-ads:20.4.0'是依赖于androidx.work:work-runtime:2.1.0. 我通过固定一个固定版本androidx.work:work-runtime来解决它,com.google.android.gms:play-services-ads如下所示:

implementation 'com.google.android.gms:play-services-ads:20.4.0'
constraints {
    implementation('androidx.work:work-runtime:2.7.0') {
        because 'play-services-ads depends on work-runtime:2.1.0 which is not compatible with targetSdk 31, but work-runtime:2.7.0 is'
    }
}

这将强制com.google.android.gms:play-services-ads使用work-runtime:2.7.0

我的直觉是,在你的情况下,这是有问题的依赖:

implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'

如果没有,您可以使用以下 gradle 命令查找所有依赖的库work-runtime

./gradlew -q app:dependencyInsight --dependency work-runtime --configuration debugCompileClasspath

如上所述,寻找那些取决于work-runtime版本小于2.7.0并固定到它们的那些。2.7.0

希望有帮助。

于 2021-11-15T12:50:02.253 回答
1

经过大量试验和错误后,我在我的应用程序中发现这种依赖性是问题所在:com.google.android.ump:user-messaging-platform:2.0.0

删除它阻止了我的应用程序崩溃。不幸的是,我还没有找到一种方法来使用它而不会崩溃。

于 2021-12-05T19:10:20.290 回答
1

我和你遇到了类似的问题。尝试在您的 gradle 文件中添加: implementation 'androidx.work:work-runtime:2.7.0' 以便能够创建您的项目。(即使您没有使用该库中的任何内容)

参考:https://groups.google.com/g/google-admob-ads-sdk/c/Yu5cemkP7fY

于 2021-11-12T06:47:24.270 回答
0

对于具有 31 个目标 sdk 的应用程序,您必须使用意图过滤器将导出的标志设置为您的 android 组件。您可以在官方文档中阅读更多内容https://developer.android.com/guide/components/intents-filters

您在清单文件中的组件必须如下所示

<activity android:name="LoginActivity" android:exported="true">
    <!-- This activity is the main entry, should appear in app launcher -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
于 2021-11-04T19:29:07.343 回答
0

1.尝试更新你的依赖

2.重建你的项目

于 2021-11-05T03:36:55.240 回答