在Android上运行cordova应用程序时,失败INSTALL_PARSE_FAILED_MANIFEST_MALFORMED <provider>具有空权限

时间:2018-10-20 14:38:39

标签: android cordova ionic-framework ionic3 cordova-plugins

我有一个运行良好的小型Ionic机器人。升级到Android 7.1 SDK后,运行cordova run --target=emulator-5554 android --verbose时出现以下错误:

Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl444999769.tmp/base.apk (at Binary XML file line #103): <provider> has empty authorities attribute]

这是platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml的第103行:

<provider
    android:name="com.marianhello.bgloc.sync.DummyContentProvider"
    android:authorities="@string/content_authority"
    android:exported="false"
    android:syncable="true" />

在我看来,好像定义了Authority属性,但是在一些在线示例中,我看到其中有应用程序名称,而我却拥有@string/content_authority。不幸的是,编辑AndroidManifest.xml毫无价值。

Package.json:

{
  "name": "travellogapp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "^6.1.10",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/background-geolocation": "^4.15.0",
    "@ionic-native/core": "^4.15.0",
    "@ionic-native/geolocation": "^4.15.0",
    "@ionic-native/google-maps": "^4.14.0",
    "@ionic-native/splash-screen": "~4.15.0",
    "@ionic-native/status-bar": "~4.15.0",
    "@ionic/storage": "2.2.0",
    "cordova-android": "^7.1.1",
    "cordova-android-play-services-gradle-release": "^1.4.4",
    "cordova-browser": "^5.0.4",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-googlemaps": "^2.4.6",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^2.2.0",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.0",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-mauron85-background-geolocation": {
        "ICON": "@mipmap/icon",
        "SMALL_ICON": "@mipmap/icon",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": ".account",
        "CONTENT_AUTHORITY": "",
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "23+"
      },
      "cordova-android-play-services-gradle-release": {
        "PLAY_SERVICES_VERSION": "15.+"
      },
      "cordova-plugin-geolocation": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "AIzaSyCplUKcqiMjv8-OJHQu1yoCmm0uK_rEtrA",
        "API_KEY_FOR_IOS": "AIzaSyCplUKcqiMjv8-OJHQu1yoCmm0uK_rEtrA",
        "PLAY_SERVICES_VERSION": "15.0.1",
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      }
    },
    "platforms": [
      "browser",
      "android"
    ]
  }
}

1 个答案:

答案 0 :(得分:1)

我在写问题时就已经弄清楚了。

provider标签由cordova-plugin-mauron85-background-geolocation引入。行android:authorities="@string/content_authority"表示authorities值是在称为string的{​​{1}}(变量)中定义的。您将在content_authority和'packgage.json'中找到定义的变量:

config.xml

由于某种原因,它最终对我来说是空的。删除并添加该插件可通过将其设置为来修复它:

"cordova-plugin-mauron85-background-geolocation": {
        ...
        "CONTENT_AUTHORITY": ""
      }