gpt4 book ai didi

android - 更改android API的正确方法

转载 作者:行者123 更新时间:2023-12-03 05:14:37 24 4
gpt4 key购买 nike

我试图通过使用android studio将Android API从23降低到16,但是在运行项目时出现错误。我已经安装了SDK版本18。

之前

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"


defaultConfig {
applicationId "com.example.project.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}


apply plugin: 'com.android.application'

android {
compileSdkVersion 16
buildToolsVersion "23.0.2"


defaultConfig {
applicationId "com.example.project.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}

错误
  Error:(231, 62) error: diamond operator is not supported in -source 1.6
(use -source 7 or higher to enable diamond operator)

清洁工程后
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldltr-v21\values-ldltr-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldrtl-v23\values-ldrtl-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v17\values-v17.xml
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v21\values-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.

有人可以告诉我如何解决这个问题吗?

enter image description here

最佳答案

您的问题是您正在使用较低的SDK编译应用程序

compileSdkVersion 18

在SDK版本18中,您不支持Material Desgin:
<style name="Base.Widget.AppCompat.Spinner.Underlined" parent="android:Widget.Material.Spinner.Underlined"/>

您还可以通过在Gradle构建中添加以下依赖项来将Material Design集成到您的应用中:
compile "com.android.support:appcompat-v7:21.0.+"

检查此链接:
android-developers

你得到这个:
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldltr-v21\values-ldltr-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-ldrtl-v23\values-ldrtl-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v17\values-v17.xml
C:\Users\tongws\AndroidStudioProjects\MyApplication1\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v21\values-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.

因为编译器找不到资源,所以它是我从链接发布的解决方案很旧并且没有这些资源。可能是您正在使用的资源已添加到AppCompact的较新版本中,因此您需要在android studio中创建一个新的应用程序项目并复制Java文件或更改设计以支持较低的SDK

还要检查您是否已从Android SDK Manager下载了SDK。
如果要在应用程序中使用它们,则需要这些工具和资源。

关于android - 更改android API的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34713775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com