【问题标题】:Can I remove the android-support-v4.jar library?我可以删除 android-support-v4.jar 库吗?
【发布时间】:2013-01-17 00:45:13
【问题描述】:

创建项目时,默认自带这个库:

android-support-v4.jar

我可以删除它吗?如果我删除库会怎样?该应用会在某些手机中停止运行吗?

【问题讨论】:

    标签: android android-library android-support-library


    【解决方案1】:

    我可以删除它吗?

    你可以试试。

    如果我删除该库会怎样?

    您将无法使用它提供的任何东西,例如片段 backport、ViewPager 等。

    该应用会在某些手机中停止运行吗?

    您将首先得到构建错误。

    【讨论】:

      【解决方案2】:

      如果您使用的是 Eclipse,并且您的项目在删除 android-support-v4 jar 后标有红色感叹号,请关闭并重新启动 Eclipse,它应该会自行恢复。 (或者您可以尝试关闭并重新打开项目。)

      【讨论】:

        【解决方案3】:

        如果您不使用当前 SDK 目标不可用的 API,则可以安全地删除它。

        【讨论】:

          【解决方案4】:

          它是一个支持库。你可以在这里阅读:

          如果您不使用此 API,您可以安全地删除它。

          【讨论】:

            【解决方案5】:

            我就是这么做的。所以我在所有项目中都遇到了多个错误,比如

            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. 
            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
            ...\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
            ...\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
            

            这意味着上述资源不再可用于我的项目。

            然后我继续添加v7 appcompat,我得到了无法摆脱我的错误。于是我把它删了,还误把盘里的项目也删了,所以安装了它的残余(我猜),结果也不好:

            [2014-12-07 06:25:16 - android-support-v7-gridlayout] Unable to resolve target 'android-7'
            [2014-12-07 06:25:16 - android-support-v7-mediarouter] Unable to resolve target 'android-17'
            [2014-12-07 06:25:16 - android-support-v7-palette] Unable to resolve target 'android-7'
            [2014-12-07 06:25:17 - android-support-v7-gridlayout] Unable to resolve target 'android-7'
            [2014-12-07 06:25:17 - android-support-v7-palette] Unable to resolve target 'android-7'
            [2014-12-07 06:25:22 - android-support-v7-mediarouter] Unable to resolve target 'android-17'
            
            
            ...\sdk\extras\android\support\v7\mediarouter\res\values\styles.xml:18: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'.
            ...\sdk\extras\android\support\v7\mediarouter\res\values\styles.xml:28: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'.
            ...\sdk\extras\android\support\v7\mediarouter\res\values\styles.xml:18: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'.
            ...\sdk\extras\android\support\v7\mediarouter\res\values\styles.xml:28: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'.
            [2014-12-07 06:25:26 - android-support-v7-mediarouter] 
            

            所以,不要这样做!

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2014-10-22
              • 1970-01-01
              • 1970-01-01
              • 2013-06-03
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多