將完成的應用程式包上傳到 Google Play 控制臺時,我遇到了一個問題。下載后,我收到此訊息:
“該應用程式無法根據設備配置宣告不同版本的 Google Play 服務。找到以下版本:[0, 12451000]”
該應用程式顯示底部智能橫幅(Google Ads),使用網路,除了演算法之外,它并沒有做更多的事情。
構建.gradle:
ext {
version = '1.0'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0-alpha09'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
構建.gradle:應用程式:
plugins {
id 'kotlin-android'
id 'org.jetbrains.kotlin.kapt'
id 'com.android.application'
}
android {
...
signingConfigs {
debug {
...
}
release {
...
}
}
compileSdk 32
buildToolsVersion '30.0.3'
defaultConfig {
minSdk 19
targetSdk 32
versionName '1.0'
versionCode 100
multiDexEnabled true
...
}
buildFeatures {
//noinspection DataBindingWithoutKapt
dataBinding true
viewBinding true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
beta {
applicationIdSuffix ".beta"
versionNameSuffix "-beta"
}
release {
applicationIdSuffix ".release"
versionNameSuffix "-release"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility "11"
targetCompatibility "11"
}
kotlinOptions {
jvmTarget = "11"
}
ndkVersion '25.0.8221429 rc2'
flavorDimensions "level"
productFlavors {
free {
...
dimension "level"
versionCode 100
versionName "1.0"
targetSdk 32
minSdk 19
signingConfig signingConfigs.release
}
pro {
...
dimension "level"
versionCode 100
versionName "1.0"
targetSdk 32
minSdk 19
signingConfig signingConfigs.release
}
}
sourceSets {
free {
java { srcDirs 'src/free/java' }
res { srcDirs 'src/free/res' }
}
pro {
java { srcDirs 'src/pro/java' }
res { srcDirs 'src/pro/res' }
}
}
lint {
checkReleaseBuilds false
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1-native-mt'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1-native-mt'
implementation 'androidx.appcompat:appcompat:1.6.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'io.reactivex.rxjava3:rxjava:3.1.4'
implementation 'com.google.android.gms:play-services-ads:20.6.0'
implementation 'com.android.support:multidex:1.0.3'
}
task wrapper(type: Wrapper) {
gradleVersion = '7.3'
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingLeanbackLauncher">
<!-- Need to listen to UDP datagrams -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<!-- For Android S devices & GMA SDK version 20.3.0 or lower -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<!-- Support Android TV and do not require a touchscreen -->
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/MyTheme.Blue.SplashScreen">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="<APP_KEY>" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".ActivitySplash"
android:exported="true"
android:theme="@style/MyTheme.Blue.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Preference activity -->
<activity
android:name=".ActivityMain"
android:exported="true"
android:theme="@style/MyTheme.Blue.SplashScreen">
</activity>
</application>
</manifest>
我查看過的與該問題相關的鏈接:
無法根據設備配置
宣告不同版本的 Google Play 服務 應用程式無法根據設備配置宣告不同版本的 Google Play 服務 無法宣告不同版本的 Google Play
服務關于設備配置
https://issuetracker.google.com/issues/223240936#comment21
https://issuetracker.google.com/issues/223240936
我做了什么:
- 深入研究 Gradle 檔案以更好地理解(插件、實作)。老實說,我從來沒有做過這項作業,因為它總是與我剛剛適應的基本 Gradle 一起作業。這是一個調整許多不一致之處的機會(盡管可能仍然存在一些)。
- 請求谷歌開發者支持(還沒有答案)
- 當然:清理專案,使現金無效
但我仍然完全陷入困境。我不知道如何解決這個問題。
這是我在這個論壇上的第一篇文章,盡管十多年來一直在深入探索 stackoverflow。直到現在,我一直設法通過在 stackoverflow、其他論壇、檔案上找到解決方案來解決問題。上面的所有鏈接都沒有幫助。
誰能幫我嗎?最好的祝福
uj5u.com熱心網友回復:
編輯:該錯誤現已修復,現在即使使用 7.3.0-* 也應該可以正常作業
目前 Play Console 中存在使用 Android Gradle 插件 7.3.0-alphaXX 構建的應用程式的錯誤。如果您在修復之前恢復到 7.2 0,這應該會解除對您的阻止。
uj5u.com熱心網友回復:
好的,問題(ssssss)似乎解決了。主要的關鍵是@Pierre 對有問題的 Android Gradle 插件 7.0.6-alpha06 的建議,以替換為com.android.tools.build:gradle:7.2.0-rc01( 或 - Epsilon 版本)。當上傳到 Google Play 控制臺時,它顯然解決了上述多個 Google Play 版本的初始問題。
我失去的大部分時間都在 Gradle 中,并且庫包括 build.gradle 語法,與晦澀的錯誤訊息相關聯。作為開發人員,我們確切地知道我們匯入了哪些庫、我們選擇了哪些版本以及為什么。我們要不要?嗯,不,我們大多數人都沒有(從開發人員到經理),除非在某些情況下。我們 100% 專注于我們的應用程式:功能、影像、性能、資料庫、演算法、客戶體驗……IDE 和 Gradle 只是實作目標的一種手段,而不是目標。
Gradle 是一個可以做任何事情的天才工具,即使是由杰出工程師構思的早晨咖啡。但它不是面向最終用戶/開發人員的。我不想了解 Gradle 的全部花里胡哨,我只想打通我的專案開發。
我會為各種型別的專案建議一組可以重用和調整的示例,而不是那些只有幾個專案相關的廣泛參考檔案。
對于遇到以下錯誤的 Google Play 控制臺,我也可以這樣說:
- 版本代碼 xxx 已被使用。嘗試另一個版本代碼。:只需增加您的代碼版本(整數格式)
- 您的 APK 或 Android App Bundle 需要具有包名稱 xx.xxxxxxx.free.release:您在 app/variant/flavors 前綴中混入了某處
- 您的 Android App Bundle 使用錯誤的密鑰進行簽名。: 使用不同鍵多次上傳時拋出。然后你必須找出控制臺“選擇”了哪一個......
- Android App Bundle 未簽名。: 表示您嘗試上傳帶有 Debug 標記的捆綁包
- 應用無法根據設備配置宣告不同版本的 Google Play 服務。找到了以下版本: [0, 12451000] : gradle 7.0.6-alpha06 庫中的錯誤再次,非常感謝@Pierre 讓我通過。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/465312.html
