我如何让我的 ionic 应用程序以 API 级别 28 及以上为目标

toc*_*gua 10 android android-studio ionic3 angular

从今天开始,我一直在尝试上传我的 ionic 应用程序,发现谷歌将他们的应用程序规则更改为目标 API 级别 28 及以上,我的目标是 27,以便留下来。

我得到的所有帮助都没有为我工作。尝试 7 后,我已将我的 codova android 升级到 8.0.0,我在 config.xml 中添加了这一行 "" 仍然没有用。请帮忙

我的 config.xml

<widget id="xxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>xxx</name>
    <description>xxx</description>
    <author email="evensatowind@gmail.com" href="http://github.com/satowind">Sato Wind</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="android-targetSdkVersion" value="28" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="19" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="500" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <engine name="android" spec="8.0.0" />
</widget>
Run Code Online (Sandbox Code Playgroud)

我的 build.gradle

   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }

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

        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }

    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误

Your app currently targets API level 27 and must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 28
Run Code Online (Sandbox Code Playgroud)

请帮助您找到适合您的解决方案。

小智 22

更改值后 config.xml

<preference name="android-targetSdkVersion" value="28" />
Run Code Online (Sandbox Code Playgroud)

您需要删除android文件夹并重新创建它

ionic cordova platform remove android
ionic cordova platform add android
Run Code Online (Sandbox Code Playgroud)


Joe*_*Joe 12

对于带有 ionic v5.0 的 API 级别 29。在 android 块中添加首选项。

<platform name="android">
    <preference name="android-targetSdkVersion" value="29" />
    /* Other code */
</platform>
Run Code Online (Sandbox Code Playgroud)

然后删除安卓

ionic cordova platform remove android
Run Code Online (Sandbox Code Playgroud)

并再次添加 android (你需要 @lastest )。

ionic cordova platform add android@latest
Run Code Online (Sandbox Code Playgroud)


Bun*_*nka 7

将此添加到您的 config.xml <preference name="android-targetSdkVersion" value="28" />