无法构建 apk,firebase_admob 出错
Unable to build apk, firebase_admob making Error
我正在尝试构建 apk,但 firebase admob 出现问题,如果我 运行 没有 firebase_admob
那么 apk 可以完美运行并且构建没有任何错误如何解决该问题?
我收到这个错误:
Execution failed for task ':firebase_admob:verifyReleaseResources' in this case.
我正在使用firebase_admob: ^0.5.2
这个版本,我什至尝试了一些最新版本,但问题仍然存在。
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
你在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'
}
您似乎还没有将项目迁移到 AndroidX
,您需要做的就是在 IDE 中使用
Refactor > Migrate to AndroidX
之后
File > Invalidate Caches and Restart
我遇到了类似的错误。但我想建议你制作 appbundle,这是上传应用程序的最佳选择。 运行 flutter build appbundle
使用 google 进行签名注册并上传。我用这个解决它。
我正在尝试构建 apk,但 firebase admob 出现问题,如果我 运行 没有 firebase_admob
那么 apk 可以完美运行并且构建没有任何错误如何解决该问题?
我收到这个错误:
Execution failed for task ':firebase_admob:verifyReleaseResources' in this case.
我正在使用firebase_admob: ^0.5.2
这个版本,我什至尝试了一些最新版本,但问题仍然存在。
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
你在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'
}
您似乎还没有将项目迁移到 AndroidX
,您需要做的就是在 IDE 中使用
Refactor > Migrate to AndroidX
之后
File > Invalidate Caches and Restart
我遇到了类似的错误。但我想建议你制作 appbundle,这是上传应用程序的最佳选择。 运行 flutter build appbundle
使用 google 进行签名注册并上传。我用这个解决它。