Unable to build apk, firebase_admob making Error

2020-04-14 16:09发布

问题:

I am trying to build apk but firebase admob is making problem, if I run without firebase_admob then apk works perfectly and built without any error how to resolve that issue?

I am getting this error :

Execution failed for task ':firebase_admob:verifyReleaseResources' in this case.

I am using firebase_admob: ^0.5.2 this version of it I even try some latest versions but the problem is still there.

C:\Users\Waqas\AndroidStudioProjects\gtvsports1>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle...                                              1.3s
Resolving dependencies...                                           4.7s
Running Gradle task 'assembleRelease'...


FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':firebase_admob:verifyReleaseResources'.

> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

  C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:304: error: resource android:attr/fontVariationSettings not foun
d.

  C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:305: error: resource android:attr/ttcIndex not found.

  error: failed linking references.





* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.



* Get more help at https://help.gradle.org



BUILD FAILED in 3m 10s
Running Gradle task 'assembleRelease'...                          190.9s (!)
Gradle task assembleRelease failed with exit code 1

回答1:

I was facing similar error. but I would like to suggest you to make appbundle which is the best option to upload app. Run flutter build appbundle sign it with google play store signing enrollment and upload. I resolve it with this.



回答2:

Seems like you haven't migrated your project to AndroidX, all you need to do is, in your IDE use

Refactor > Migrate to AndroidX

After this

File > Invalidate Caches and Restart


回答3:

Did you add the dependencies in Android/app/build.gradle?

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    api 'com.google.firebase:firebase-core:16.0.9'
    api 'com.google.firebase:firebase-ads:16.0.1'
}