简体   繁体   English

Android设计支持库设置麻烦

[英]Android design support library setup trouble

I'm completely confused with implementation of the Android design support library. 我对Android设计支持库的实现完全感到困惑。 I tried to do almost everything advised on Stack Overflow, but I am still having compile-time errors on each widget from the design support library (Error parsing XML: Unbound prefix). 我试图做所有关于堆栈溢出的建议,但是我在设计支持库中的每个小部件上仍然遇到编译时错误(解析XML:未绑定前缀)。

I'm developing in Eclipse. 我正在Eclipse中进行开发。 Here's what have I done: 这是我所做的:

  1. Downloaded last Android Support Library (23.0.1), Android Support Repository (21), API 23. 下载了最新的Android支持库(23.0.1),Android支持存储库(21),API 23。

  2. Imported android-support-v7-appcompat as a library, android-support-v7-appcompat为库,
    Project Properties - Android - Add. 项目属性-Android-添加。

  3. Copied last downloaded android-support-design.jar , 复制了上次下载的android-support-design.jar
    android-support-v4.jar , android-support-v7.jar android-support-v4.jarandroid-support-v7.jar
    into libs folder of the project and imported them as: Profect Properties - Java Build Path - Libraries Add Jars and checked them on Order and Export. 到项目的libs文件夹中,并将它们导入为:Profect Properties-Java构建路径-库添加Jars并在Order and Export上检查它们。

  4. I set up targetSdkVersion="23" in manifest, target=android-23 in project.properties. 我在清单中设置了targetSdkVersion="23" ,在project.properties中设置了target=android-23

  5. Changed theme in styles.xml as: styles.xml主题更改为:

My layout looks like this: 我的布局如下所示:

<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="192dp" >

    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" >

        <android.support.v7.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin" />
    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

Any suggestions? 有什么建议么?

No doubt Android Studio is Good for Android development but still have a solution for this problem in eclipse. 毫无疑问, Android Studio对Android开发有好处,但是在日食方面仍然可以解决此问题。 I have also face same problem then find solution like this. 我也遇到同样的问题,然后找到这样的解决方案。

It work for me hope same for You. 它对我有用,希望对您也一样。

First Step:- find .aar file for design-23.0.1.aar 第一步:-找到用于design-23.0.1.aar的 .aar文件

E:\new sdk\sdk\android-sdk-windows\extras\android\m2repository\com\android\support\design\23.0.1 

Second Step:- copy that file and rename it like design-23.0.1.jar to be extract this. 第二步:-复制该文件,然后将其重命名为design-23.0.1.jar ,以提取该文件。 After unzip it you find classes.jar, res, AndroidManifest etc and follow these steps: Guided by commonsware.com 解压缩后,您可以找到classes.jar,res,AndroidManifest等,并按照以下步骤操作: commonsware.com 指导

  • Create an empty directory that will be the home for the Android library project. 创建一个空目录,该目录将成为Android库项目的主目录。 For the rest of these steps, I will refer to this as “the output directory”. 对于其余的步骤,我将其称为“输出目录”。
  • Copy the AndroidManifest.xml , res/ , and assets/ directories from the AAR into the output directory. 从AAR复制AndroidManifest.xmlres /asset /目录到输出目录。
  • Create a libs/ directory in the output directory. 在输出目录中创建一个libs /目录。 Copy into libs/ the classes.jar from the root of the unZIPped AAR, plus anything in libs/ in the AAR (eg, mediarouter-v7 has its own JAR of proprietary bits). 复制到库/的classes.jar从解压的AAR的根源,再加上什么/在库中AAR(例如,mediarouter-V7拥有自己的专利位的JAR)。
  • Decide what build SDK you want to try to use. 确定要尝试使用的构建SDK。 You might just choose the highest SDK version you have installed. 您可能只选择了已安装的最高SDK版本。 Or, you can use the android:minSdkVersion and the -vNN resource set qualifiers to get clues as to what a good build SDK might be. 或者,您可以使用android:minSdkVersion和-vNN资源集限定符来获取有关良好构建SDK可能是什么的线索。 If desired, create a project.properties file with a target=android-NNN line, where NNN is your chosen build SDK. 如果需要,用target = android-NNN行创建一个project.properties文件,其中NNN是您选择的构建SDK。 Or, you can address this in Eclipse later on. 或者,您可以稍后在Eclipse中解决此问题。
  • Import the resulting project into Eclipse, and if needed adjust the build SDK (Project > Properties > Android). 将生成的项目导入Eclipse,并在需要时调整构建SDK(“项目”>“属性”>“ Android”)。 Also, you will need to attach to this library project any library projects it depends upon (eg, mediarouter-v7 depends upon appcompat-v7). 同样,您将需要将它依赖的任何库项目附加到该库项目(例如,mediarouter-v7取决于appcompat-v7)。

Good Luck! 祝好运!

And Special thanks to commonsware !! 特别感谢commonsware

Start using Android Studio. 开始使用Android Studio。 The whole library management is very good of Android Studio. 整个库管理是Android Studio的很好。 The support for eclipse is going to end from google so anyhow you have to switch. 对eclipse的支持将从Google终止,因此无论如何都必须切换。

Hey you are attaching android-support-v7-appcompat for two times. 嘿,您要附加两次android-support-v7-appcompat Just use it only one time either use as library and add in properties OR put lib file in libs folder. 只需使用一次即可,要么用作库并添加属性,要么将lib文件放在libs文件夹中。

Just remove only one and try to clean and rebuild project again. 只需删除一个,然后尝试清理并重新生成项目。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM