如何使用 android studio 开发遗留 Android 应用程序 (api>=10)?

How to develop legacy Android app (api>=10) with android studio?

我正在尝试用姜饼 api 10.

为我(非常)老的 Android phone 开发一个应用程序

但是 android 工作室作为 IDE 问题似乎永远存在:

…这就是我不知道如何继续的关键

正如我所想,这不可能是真的,一个项目抛出那么多错误,我没有创建一个 class 也没有写一行代码,我尝试从命令行构建.

它有效,但我已经习惯了 IDE-功能并且不想错过它们。所以我的问题是:

如何使用 android studio 为 api 关卡开发遗留 android 应用程序?
是否有继续将项目安装到 api 10 的指南?

我是否在 "right" 路径上?

是否有 api 级别 10 应用程序的骨架项目,我可以导入它(好像我可以在项目向导中选择 api 10)?

我知道原因,Google 不再支持 api<14。

我仍然不明白为什么我不能使用我非常健康的硬件。
我仍然希望能够为我的旧 phone.

编写一个简单的应用程序

¹ 错误日志:

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'
}

您可以为API >= 9 创建Android 项目,制作项目没有技术限制。唯一的问题是 Google 不支持 API < 14 以下的旧 phone。Google 从 26 开始的支持库不支持 api < 14。因此,您需要使用支持库 25。您还需要使用允许 API 版本 10 的支持测试。

我已经为您创建了一个框架项目。您可以在 https://github.com/isnotmenow/AndroidProjectForAPI9

获取

了解支持 API9 的支持测试库: https://developer.android.com/topic/libraries/testing-support-library/release-notes.html#espresso_300_runner_100_rules_100_androidtestorchestrator_100_2017-07-25_announcement