我正在运行一个针对 Android 19 的反建项目。我正在尝试使用Android 5.0发布的 Android设计库中引入的TabLayout。
当我尝试从命令行构建项目时,我发现Android设计库需要 appcompat 。我添加了appcompat,并删除了v21和v23的资源文件夹,因为我的应用程序仅支持v19(并且它给了我错误)。我设法使用ant debug来构建Appcompat,但是当我尝试构建设计库时,我收到错误
[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并进行更新lib-project并清理,但无济于事。
使用appcompat,我在project.properties中列出了这样的依赖
target=android-19
android.library.reference.1=../appcompat/
问题
答案 0 :(得分:1)
为什么我会收到此错误
将您的target
更改为android-23
。您的构建目标(Android Studio中称为compileSdkVersion
的内容)应与您正在使用的Android支持库的目标匹配。
Android 5.0发布的Android设计库是否需要Android 5.0?
没有。 AFAIK,它可以回溯到API级别7,appcompat-v7
也是如此。它需要针对较新版本的Android 编译,因为它在较新的Android设备上运行时有条件地使用较新Android版本的API。
在appcompat中删除v21,v23资源文件夹是否安全,以便我可以使用目标19构建它?
没有