【问题标题】:Ionic Android No resource found that matches the given name.. cardBackgroundColorIonic Android 找不到与给定名称匹配的资源.. cardBackgroundColor
【发布时间】:2016-04-13 10:06:29
【问题描述】:

在尝试构建项目时遇到 Ionic 问题。在:processDebugResources 我收到如下错误:

Failed to generate resource table for split ''
/Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/res/debug/values-v23/values.xml:6: error: Error: No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/johnhoulder/Library/Android/sdk/build-tools/23.0.3/aapt package -f --no-crunch -I /Users/johnhoulder/Library/Android/sdk/platforms/android-22/android.jar -M /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/res/debug -A /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/assets/debug -m -J /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/generated/source/r/debug -F /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.munch_delivery.app -0 apk --output-text-symbols /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/symbols/debug
  Error Code:
    1
  Output:
    Failed to generate resource table for split ''
    /Applications/MAMP/htdocs/APP/consumer/platforms/android/build/intermediates/res/debug/values-v23/values.xml:6: error: Error: No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.959 secs

/Applications/MAMP/htdocs/APP/consumer/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                    ^
Error code 1 for command: /Applications/MAMP/htdocs/APP/consumer/platforms/android/gradlew with args: cdvBuildDebug,-b,/Applications/MAMP/htdocs/APP/consumer/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true

插件:

  • cordova-plugin-facebook4
  • cordova-plugin-whitelist
  • onesignal-cordova-plugin

AndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.munch_delivery.app" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/fb_app_name" />
        <activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/fb_app_name" android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false" xmlns:amazon="http://schemas.amazon.com/apk/res/android" />
        <service android:exported="false" android:name="com.onesignal.ADMMessageHandler" />
        <receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
            <intent-filter>
                <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
                <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
                <category android:name="com.munch_delivery.app" />
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
</manifest>

编辑:

设法通过将所有出现的com.facebook.android:facebook-android-sdk:4.+ 更改为com.facebook.android:facebook-android-sdk:4.8.0 来找到临时解决方案。是否有任何永久解决方案或者这是正确的方法?

【问题讨论】:

    标签: android cordova ionic-framework


    【解决方案1】:

    对于那些出于同样的原因为他们损坏的 phonegap 构建应用程序寻找解决方案的可怜人来说,这里是如何在 config.xml 的插件声明中使用特定的 github 提交:

    <plugin spec="https://github.com/jeduan/cordova-plugin-facebook4#aff9a08a86cc6c6a18019f7adc2896ddf97c11cd" source="git" >
      <param name="APP_ID" value="YOUR_APP_ID"/>
      <param name="APP_NAME" value="YOUR_APP_NAME"/>
    </plugin> 
    

    【讨论】:

      【解决方案2】:

      所以这显然已在插件中修复但尚未发布

      https://github.com/jeduan/cordova-plugin-facebook4/commit/aff9a08a86cc6c6a18019f7adc2896ddf97c11cd

      在我的package.json我改变了

      {
        "variables": {
          "APP_ID": "REPLACE_FACEBOOK_APPID",
          "APP_NAME": "REPLACE_FACEBOOK_APPNAME"
        },
        "locator": "cordova-plugin-facebook4@1.6.3",
        "id": "cordova-plugin-facebook4"
      },
      

      {
        "variables": {
          "APP_ID": "REPLACE_FACEBOOK_APPID",
          "APP_NAME": "REPLACE_FACEBOOK_APPNAME"
        },
        "locator": "https://github.com/jeduan/cordova-plugin-facebook4#aff9a08a86cc6c6a18019f7adc2896ddf97c11cd",
        "id": "cordova-plugin-facebook4"
      },
      

      然后您必须删除旧插件并安装新插件。我在 bash 中使用

      cd myproject
      rimraf platforms/
      rimraf plugins/
      ionic state restore
      

      cd myproject
      cordova plugin rm cordova-plugin-facebook4
      ionic state restore
      

      【讨论】:

        【解决方案3】:

        将字符串资源添加到(我使用的是 linux ubuntu,这是我的 ionic 项目路径)文件:/home/user/js/fb4/platforms/android/app/src/main/res/values/strings.xml

        <string name="fb_app_id">59523234234</string>
        <string name="fb_app_name">hajmo.ba</string>
        

        我的项目现在可以运行了!

        【讨论】:

          【解决方案4】:

          如果您在本地存储库中有插件,您可以替换“plugin.xml”文件中的以下行:

          <framework src="com.facebook.android:facebook-android-sdk:4.+"/>
          

          通过

          <framework src="com.facebook.android:facebook-android-sdk:4.8.+"/>
          

          然后从您的项目中删除 facebook-4 插件,然后再从您的本地存储库中再次添加它,该存储库现在包含更正。

          或者你可以听从@jakub.g 的建议

          【讨论】:

            【解决方案5】:

            我没有足够的声誉将其添加为评论,因此我将其发布为答案。我无法使用@suprandr 和@jakub.g 指定的方法解决这个问题,对我有用的是替换每次出现的“com.facebook.android:facebook-android-sdk:4.+” 在我的 Cordova 项目中带有“com.facebook.android:facebook-android-sdk:4.8.0”。

            注意:这只是一个临时修复

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2016-06-28
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多