【问题标题】:Build errors while using Android library project使用 Android 库项目时生成错误
【发布时间】:2012-07-09 09:05:17
【问题描述】:

我正在尝试在 github 上使用这个库项目:

https://github.com/pakerfeldt/android-viewflow

这个 Android 库项目提供水平滑动。

我将解释我是如何尝试使用这个库的:

  1. 我从 github 下载了这个项目,并用“现有项目到工作区”导入了“viewflow”项目。 (Eclipse 给出了一些错误,但我修复了它们。这不是问题。)
  2. 我创建了一个名为“test”的新 android 项目。
  3. 我将 viewflow 项目添加到我的测试项目的构建路径中。 (使用Java构建路径->项目->添加)
  4. 这是我的 main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.example.test"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/header_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="vertical" >

        <org.taptwo.android.widget.TitleFlowIndicator
            android:id="@+id/viewflowindic"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            app:clipPadding="5dp"
            app:footerColor="#FFFFC445"
            app:footerLineHeight="2dp"
            app:footerTriangleHeight="10dp"
            app:selectedColor="#FFFFC445"
            app:selectedSize="12dp"
            app:textColor="#FFFFFFFF"
            app:textSize="11dp"
            app:titlePadding="10dp" >
        </org.taptwo.android.widget.TitleFlowIndicator>
    </LinearLayout>

    <org.taptwo.android.widget.ViewFlow
        android:id="@+id/viewflow"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:duplicateParentState="true" >
    </org.taptwo.android.widget.ViewFlow>
</LinearLayout>

但是 Eclipse 给出了这些错误:

Description Resource    Path    Location    Type
R cannot be resolved to a variable  Main.java   /test/src/com/example/test  line 14 Java Problem
R cannot be resolved to a variable  Main.java   /test/src/com/example/test  line 19 Java Problem
error: No resource identifier found for attribute 'titlePadding' in package 'com.example.test'  main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'textSize' in package 'com.example.test'  main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'textColor' in package 'com.example.test' main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'selectedSize' in package 'com.example.test'  main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'selectedColor' in package 'com.example.test' main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'clipPadding' in package 'com.example.test'   main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'footerColor' in package 'com.example.test'   main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'footerLineHeight' in package 'com.example.test'  main.xml    /test/res/layout    line 15 Android AAPT Problem
error: No resource identifier found for attribute 'footerTriangleHeight' in package 'com.example.test'  main.xml    /test/res/layout    line 15 Android AAPT Problem

我导入了它的示例项目 (https://github.com/pakerfeldt/android-viewflow/tree/master/viewflow-example),它运行良好!

问题可能与命名空间有关,但我无法解决此问题。

【问题讨论】:

  • R 无法解析为变量 => 尝试清理并构建
  • 首先清理库项目,然后在构建路径中删除添加到您项目中的库项目,现在再次将库项目添加到您的项目并检查。
  • 我试过了,还是不行。如果我完全删除 org.taptwo.android.widget.TitleFlowIndicator,就没有问题。我猜 xmlns:app 行有问题。
  • 清理项目,修复项目,删除bin文件夹,重启eclipse。
  • 只需更新您的android应用...右键单击您的项目>>属性>>选择android并将其更新到高级。

标签: android library-project


【解决方案1】:

app:selectedSize="12dp" 去掉这一行

【讨论】:

    猜你喜欢
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 2019-03-01
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    相关资源
    最近更新 更多