Flutter 在Android极光推送遇到的问题

发布于 1 年前 作者 phonegap100 435 次浏览 最后一次编辑是 1 年前 来自 分享

1、如果提示下面错误:

```
uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [:jpush_flutter] D:\flutter2x\flutter_jpush\build\jpush_flutter\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
            or increase this project's minSdk version to at least 17,
            or use tools:overrideLibrary="com.jiguang.jpush" to force usage (may lead to runtime failures)
```

请修改:minSdkVersion版本为17

修改方法:找到android/app/build.gradle 修改 minSdkVersion版本为17

2、如果提示下面错误:

android\app\src\main\AndroidManifest.xml:5:9-42 Error:
        Attribute application@name at AndroidManifest.xml:5:9-42 requires a placeholder substitution but no value for <applicationName> is provided.D:\getx\flutter_jpush\android\app\src\debug\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

请参考https://github.com/jpush/jpush-flutter-plugin/issues/339

修改/android/app/build.gradle 配置方法

以前:

android: {
  ....
  defaultConfig {
  
    ...

    manifestPlaceholders = [
        JPUSH_PKGNAME : applicationId,
        JPUSH_APPKEY : "appkey", // NOTE: JPush 上注册的包名对应的 Appkey.
        JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
    ]
  }    

替换为:(注意+号)

android: {
  ....
  defaultConfig {  
    ...     
     manifestPlaceholders = manifestPlaceholders+ [
            JPUSH_PKGNAME : applicationId,
            JPUSH_APPKEY : "17d78ecf32c322db169a1d98",
            JPUSH_CHANNEL : "developer-default",
      ]
  }   
回到顶部