我正在运行一个针对Android 19的反构建项目。我正在尝试使用在Android 5.0发布的Android设计库中引入的TabLayout。
当我尝试从命令行构建我的项目时,我发现Android设计库需要appcompat。我添加了appcompat,我删除了v21和v23的资源文件夹,因为我的应用程序只支持v19(它给了我错误)。我设法让Appcompat构建使用ant调试,但当我试图构建设计库,我得到错误
[javac] Compiling 5 source files to /home/yunshen/workspace/ui-android/design/bin/classes
[javac] /home/yunshen/workspace/ui-android/design/src/main/java/com/somedomain/design/MainActivity.java:14: error: cannot find symbol
[javac] setContentView(R.layout.activity_main);
[javac] ^
[javac] symbol: variable activity_main
[javac] location: class layout
[javac] /home/yunshen/workspace/ui-android/design/src/main/java/com/somedomain/design/MainActivity.java:21: error: cannot find symbol
[javac] getMenuInflater().inflate(R.menu.menu_main, menu);
[javac] ^
[javac] symbol: variable menu
[javac] location: class R
[javac] /home/yunshen/workspace/ui-android/design/src/main/java/com/somedomain/design/MainActivity.java:33: error: cannot find symbol
[javac] if (id == R.id.action_settings) {
[javac] ^
[javac] symbol: variable action_settings
[javac] location: class id
[javac] Note: /home/yunshen/workspace/ui-android/design/src/main/java/com/somedomain/design/MainActivity.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 3 errors
没有引用appcompat,我从做同样的事情得到这个(这就是为什么我添加了appcompat,尽管它从未被提及)
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:21: error: Error: No resource found that matches the given name: attr 'backgroundTint'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:23: error: Error: No resource found that matches the given name: attr 'elevation'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:34: error: Error: No resource found that matches the given name: attr 'elevation'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:56: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:59: error: Error: No resource found that matches the given name: attr 'textAllCaps'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:67: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:71: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:87: error: Error: No resource found that matches the given name: attr 'elevation'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:97: error: Error: No resource found that matches the given name: attr 'elevation'.
[aapt]
[aapt] /home/yunshen/workspace/ui-android/design/res/values/styles.xml:105: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'.
[aapt]
我试过删除/gen和做更新库项目和清洁,但无济于事。
对于appcompat,我已经在project中列出了依赖项。像这样的属性
target=android-19
android.library.reference.1=../appcompat/
问题- 为什么我得到这个错误
- 与Android 5.0一起发布的Android设计库需要Android 5.0吗?(这将解释我的问题)
- 在appcompat中删除v21, v23资源文件夹是否安全,以便我可以使用目标19构建它?
为什么我得到这个错误
将target
更改为android-23
。你的构建目标(在Android Studio中被称为compileSdkVersion
)应该与你正在使用的Android支持库匹配。
Android 5.0发布的Android Design Library需要Android 5.0吗?
。我敢说,它可以回到API级别7,就像appcompat-v7
一样。它需要针对较新版本的Android进行编译,因为它在较新的Android设备上运行时有条件地使用较新Android版本的api。
号在appcompat中删除v21, v23资源文件夹是否安全,以便我可以使用目标19构建它?