【发布时间】:2025-11-26 14:25:01
【问题描述】:
我正在尝试使用 Gingerbread,api 10 为我的(非常)旧的 Android 手机开发一个应用程序。
但使用 android studio 作为 IDE,问题似乎永远存在:
- 在项目向导中,仅支持 api>=14
- 所以我选择了 14 并且想稍后更改
- 我将 build.gradle(:app) 中的 minSdkVersion 更改为 10 ->
minSdkVersion 10 cannot be smaller than version 14 declared in library - 所以我将
implementation 'com.android.support:appcompat-v7:26.1.0'更改为implementation 'com.android.support:appcompat-v7:25.1.0' - 我收到错误¹,一些生成的 gradle chache 文件“values-v14.xml”缺少资源
……这就是我不知道该怎么做的重点
正如我所想,这不可能是真的,一个项目抛出了那么多错误,而且我没有创建一个类,也没有写一行代码,我尝试从命令行构建。
它有效,但我已经习惯了 IDE 功能并且不喜欢错过它们。所以我的问题是:
如何使用 android studio 开发一个 API 级别低至 10 的旧版 Android 应用程序?
是否有继续将项目安装到 api 10 的指南?
我是否走在“正确”的道路上?
是否有我可以导入的 api 级别 10 应用程序的骨架项目(好像我可以在项目向导中选择 api 10)?
我知道原因,Google 不再支持 api
我仍然不明白为什么我不能使用我完全健康的硬件。
我仍然希望能够为我的旧手机编写一个简单的应用程序。
¹错误日志:
Information:Gradle tasks [:app:assembleDebug]
/home/aik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-25.1.0.aar/2ab2d76d88a035b2d8a733b1b9a020a8/res/values-v14/values-v14.xml
Error:(8, 5) error: style attribute 'android:attr/textAllCaps' not found.
Error:resource android:style/TextAppearance.Material not found.
Error:resource android:style/TextAppearance.Material.Body1 not found.
Error:resource android:style/TextAppearance.Material.Body2 not found.
/home/aik/test_api10/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v14/values-v14.xml
Error:(5) style attribute 'android:attr/textAllCaps' not found.
Error:resource android:style/TextAppearance.Material.Button not found.
Error:resource android:style/TextAppearance.Material.Caption not found.
Error:resource android:style/TextAppearance.Material.Display1 not found.
Error:resource android:style/TextAppearance.Material.Display2 not found.
Error:resource android:style/TextAppearance.Material.Display3 not found.
Error:resource android:style/TextAppearance.Material.Display4 not found.
Error:resource android:style/TextAppearance.Material.Headline not found.
Error:resource android:style/TextAppearance.Material.Inverse not found.
Error:resource android:style/TextAppearance.Material.Large not found.
/home/aik/test_api10/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v11/values-v11.xml
Error:(6) error: resource android:attr/textColorHighlightInverse not found.
Error:(7) error: resource android:attr/textColorLinkInverse not found.
Error:(12) error: resource android:attr/textColorHighlightInverse not found.
Error:(13) error: resource android:attr/textColorLinkInverse not found.
Error:resource android:style/TextAppearance.Material.Large.Inverse not found.
Error:resource android:style/TextAppearance.Material.Widget.PopupMenu.Large not found.
Error:resource android:style/TextAppearance.Material.Widget.PopupMenu.Small not found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 10s
Information:25 errors
Information:0 warnings
Information:See complete output in console
编辑 我修改了我的 gradle:app 以匹配来自 ישו אוהב אותך 的骨架项目的那个。除了上面提到的尝试之外,我确实必须更改 compileSdkVersion、targetSdkVersion 和 androidTestImplementation。文件现在看起来像这样:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
defaultConfig {
applicationId "dj.kai.test_api10"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
// this is the last support test for api >= 9
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
【问题讨论】:
-
发布您的 gradle 文件似乎是 gradle 库或设置的问题。
-
您的评论 - 似乎就是这样。修改问题以包含工作文件。
标签: android android-studio android-hardware android-api-levels