添加oneSignal插件cordova - Ionic 2

时间:2017-09-11 10:46:42

标签: android cordova sdk ionic2 onesignal

我在我的项目中添加了onesignal-cordova-plugin,但是当我想构建(ionic cordova run android)时出现了这个错误:

Observed package id 'build-tools;26.0.0-rc1' in inconsistent location 'E:\SDK\build-tools\26.0.0-preview' (Expected 'E:\SDK\build-tools\26.0.0-rc1')
Errors during XML parse:
White spaces are required between publicId and systemId.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.]
Additionally, the fallback loader failed to parse the XML.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not resolve com.android.support:support-v4:[26.0.0,26.1.0).
     Required by:
         project : > com.onesignal:OneSignal:3.6.1
      > Could not resolve com.android.support:support-v4:[26.0.0,26.1.0).
         > Failed to list versions for com.android.support:support-v4.
            > Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml.
               > Could not GET 'https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml'.
                  > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out: connect
      > Could not resolve com.android.support:support-v4:[26.0.0,26.1.0).
         > Failed to list versions for com.android.support:support-v4.
            > Unable to load Maven meta-data from https://maven.google.com/com/android/support/support-v4/maven-metadata.xml.
               > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.
   > Could not resolve com.android.support:customtabs:[26.0.0,26.1.0).
     Required by:
         project : > com.onesignal:OneSignal:3.6.1
      > Could not resolve com.android.support:customtabs:[26.0.0,26.1.0).
         > Failed to list versions for com.android.support:customtabs.
            > Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/customtabs/maven-metadata.xml.
               > Could not GET 'https://jcenter.bintray.com/com/android/support/customtabs/maven-metadata.xml'.
                  > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out: connect
      > Could not resolve com.android.support:customtabs:[26.0.0,26.1.0).
         >

BUILD FAILED

有什么问题?我看到了同样的错误here

可能相关:

找不到请求的路径:

https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml

离子信息

cli packages: 
@ionic/cli-utils : 1.9.2 
ionic (Ionic CLI) : 3.9.2 

global packages: 
Cordova CLI : 7.0.1 
Gulp CLI : CLI version 3.9.1 
Local version 3.9.1 

local packages: 
@ionic/app-scripts : 2.1.4 
Cordova Platforms : android 6.2.3 
Ionic Framework : ionic-angular 3.5.0 

System: 
Android SDK Tools : 25.2.5 
Node : v8.1.3 
npm : 5.0.3 
OS : Windows 10

已编辑: 所以我将文件夹名称从 26.0.0-preview 更改为 26.0.0-rc1 ,我收到了一个新错误:

Errors during XML parse:
White spaces are required between publicId and systemId.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and
systemId.
javax.xml.bind.UnmarshalException
  - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and
systemId.]
Additionally, the fallback loader failed to parse the XML.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
    > Could not resolve com.android.support:support-v4:[26.0.0,26.1.0).
      Required by:
          project : > com.onesignal:OneSignal:3.6.1
       > Could not resolve com.android.support:support-v4:[26.0.0,26.1.0).
          > Failed to list versions for com.android.support:support-v4.
             > Unable to load Maven meta-data from
https://maven.google.com/com/android/support/support-v4/maven-metadata.xml.
                > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required
between publicId and systemId.
    > Could not resolve com.android.support:customtabs:[26.0.0,26.1.0).
      Required by:
          project : > com.onesignal:OneSignal:3.6.1
       > Could not resolve com.android.support:customtabs:[26.0.0,26.1.0).
          > Failed to list versions for com.android.support:customtabs.
             > Unable to load Maven meta-data from
https://maven.google.com/com/android/support/customtabs/maven-metadata.xml.
                > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required
between publicId and systemId.

1 个答案:

答案 0 :(得分:2)

最后我找到了解决方案!首先,最好看onesignal-plugin-versions;

根据:

  

2.2.0发布:

     

支持Android 2.3(API 9)支持,最低版本现为4.0.3(API 15)。

所以我们有两个选择:

  1. minSdkVersion

  2. 中增加config.xml
  3. 降低onesignal-cordova-plugin版本(ionic cordova plugin add onesignal-cordova-plugin@2.1.2