SDK版本19版Android Studio编译



我需要使用targetsdk和compilesdk版本编译我的项目(非常简单,几乎是空的)。这是我的gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 19
    buildToolsVersion '23.0.3'
    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.appsflyer:af-android-sdk:4.6.0@aar'
}

据我所知,我正在使用适当的appCompat库 - 它必须与targetsdk和compilesdk版本相同,尽管它没有使用19.0.0编译19.0.0,它说它已过时并且自动切换。至19.1.0。我什至试图完全摆脱AppCompat库(有一个暗示,在此SDK版本中,我不需要)。

gradle文件的每次更改后,我都会清洁并重新同步项目。虽然我仍然遇到相同的错误:

Error:(13) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(15) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(21) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(28) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(206) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(208) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(211) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.

我没有插入所有错误,它们几乎相同,有203个。有什么问题?

P.S。i 需要用于版本19而不是21。

在API 20中引入了材料设计。

导入时:

compile 'com.google.android.gms:play-services:8.3.0'

您确实导入appcompat-v7:22.2.0。请参阅此处的依赖项

您最多应该声明:

compile 'com.google.android.gms:play-services:5.0.89'

为什么要针对SDK19?建议始终针对最新的SDK。您的代码不会编译,因为直到SDK21才引入材料。

如果您想让您的应用与较旧的Android版本兼容,那就是Minsdkversion的目的。

请参阅AppCompat V7 R21返回values.xml中的错误?有关更多信息。

如果您确实需要使用SDK19,则必须降级其他需要SDK21 的依赖项。否则您要实现的目标是不可能的。如果这些依赖项没有获得适当的SDK来编译

,他们该如何工作

我同意R.Zagórski但是由于声誉点无法发表评论。必须了解,如果您包含需要较新版本的Android SDK的依赖项,那么您的项目将自动更新为所需版本。如果您坚持使用SDK19并希望维护材料设计外观,请考虑查看第三方库,使您模仿Google材料设计的外观。在这里,对于这些免费库来说,这是https://android-arsenal的绝佳资源。com/