Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从android Studio 2.0在API 16 Handy上运行android应用程序_Android_Android Studio - Fatal编程技术网

从android Studio 2.0在API 16 Handy上运行android应用程序

从android Studio 2.0在API 16 Handy上运行android应用程序,android,android-studio,Android,Android Studio,不幸的是,我在android开发方面没有那么丰富的经验。我为我的Mac下载了Android Studio,安装了java,并完成了developers.Android.com(,)官方文档中描述的所有工作 然后我尝试创建第一个基本项目,并在我的三星Galaxy S2 handy上运行它。不幸的是,我无法运行它,因为Android Studio抱怨我的Galaxy S2支持API 16,而该项目需要API 23(midSdk(API 23,N,预览)!=deviceSdk(API 16)) 我不清

不幸的是,我在android开发方面没有那么丰富的经验。我为我的Mac下载了Android Studio,安装了java,并完成了developers.Android.com(,)官方文档中描述的所有工作

然后我尝试创建第一个基本项目,并在我的三星Galaxy S2 handy上运行它。不幸的是,我无法运行它,因为Android Studio抱怨我的Galaxy S2支持API 16,而该项目需要API 23(
midSdk(API 23,N,预览)!=deviceSdk(API 16)

我不清楚为什么会出现这个错误,因为我在创建项目时选择了最低支持版本API 16,我必须在谷歌上搜索解决方案,并查看stackoverflow上的不同主题

我的build.gradle文件内容是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-N'
    buildToolsVersion "23.0.3"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.+'
}
我不得不把它改成:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion "23.0.3"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.+'
}
之后,我可以选择我的三星Galaxy S2并单击“运行”,但它并没有完全解决问题,我仍然无法运行我的应用程序,因为现在我从Grandle收到一些编译错误:

/Users/daniel/AndroidStudioProjects/MyApplication3/app/build/intermediates/res/merged/debug/values-ldltr-v21/values-ldltr-v21.xml
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
/Users/daniel/AndroidStudioProjects/MyApplication3/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.0.0-alpha2/res/values-v17/values-v17.xml
Error:(3, 5) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(6, 5) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(10, 5) No resource found that matches the given name: attr 'android:layout_marginEnd'.
Error:(13, 5) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(16, 5) No resource found that matches the given name: attr 'android:layout_marginStart'.
Error:(19, 5) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
Error:(19, 5) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(23, 5) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(23, 5) No resource found that matches the given name: attr 'android:paddingStart'.
Error:(27, 5) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
Error:(30, 5) No resource found that matches the given name: attr 'android:layout_toStartOf'.
Error:(33, 5) No resource found that matches the given name: attr 'android:layout_alignParentEnd'.
Error:(36, 5) No resource found that matches the given name: attr 'android:layout_toEndOf'.
Error:(36, 5) No resource found that matches the given name: attr 'android:layout_toStartOf'.
Error:(40, 5) No resource found that matches the given name: attr 'android:layout_marginStart'.
Error:(43, 5) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(43, 5) No resource found that matches the given name: attr 'android:paddingStart'.
Error:(47, 5) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(47, 5) No resource found that matches the given name: attr 'android:paddingStart'.
/Users/daniel/AndroidStudioProjects/MyApplication3/app/build/intermediates/res/merged/debug/values-v21/values-v21.xml
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:(212) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(214) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(222) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
Error:(232) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
Error:(172) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:(185) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.EditText'.
Error:(6) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:(5) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:(7) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:(8) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:(9) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:(10) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:(11) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:(12) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:(14) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:(16) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(20) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:(22) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:(23) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Subtitle'.
Error:(25) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Title'.
Error:(27) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:(29) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:(30) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
Error:(31) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
Error:(35) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(37) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
Error:(39) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:(41) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:(43) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button'.
Error:(49) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(51) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(53) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(54) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.TextView.SpinnerItem'.
Error:(55) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(57) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(161) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
Error:(163) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
Error:(165) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Error:(167) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
Error:(170) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
Error:(175) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button'.
Error:(176) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless'.
Error:(177) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless.Colored'.
Error:(180) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Small'.
Error:(181) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ButtonBar'.
Error:(182) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.CheckBox'.
Error:(183) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.RadioButton'.
Error:(184) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
Error:(188) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ImageButton'.
Error:(189) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(191) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(193) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
Error:(195) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
Error:(201) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
Error:(203) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
Error:(204) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
Error:(206) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
Error:(216) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar'.
Error:(217) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.SeekBar'.
Error:(218) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:(219) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.TextView.SpinnerItem'.
Error:(220) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
/Users/daniel/AndroidStudioProjects/MyApplication3/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.0.0-alpha2/res/values-v21/values-v21.xml
Error:(64, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(64, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(108, 5) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(111, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(155, 5) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(158, 5) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(197, 5) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(208, 5) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(242, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
/Users/daniel/AndroidStudioProjects/MyApplication3/app/build/intermediates/res/merged/debug/values-v23/values-v23.xml
Error:(37) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless.Colored'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(34) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:(35) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar.Indicator'.
Error:(36) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar.Small'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/daniel/Library/Android/sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
我甚至尝试将buildTools版本更改为17,但也没有帮助(我只是再次收到编译错误,但在不同的地方)

有人能帮我把它修好吗?我不知道为什么运行这样的常规任务会如此复杂,而且我也不明白为什么developers.android.com上的“入门”部分没有记录

另外,如果可能的话,我想了解为什么它不能从头开始工作?您可以看到,
minSdkVersion
从一开始就设置为16,但由于某些原因,它无法工作


谢谢。

有关为什么它不会以
N
为目标运行,以及使用最小SDK设置为16的已编译SDK版本的答案,请参阅。您应该能够将
compiledSdkVersion
targetSdkVersion
设置为23,并将
minSdkVersion
设置为16。@GeorgeMulligan,谢谢您的评论。嗯,我尝试将
compiledSdkVersion
设置为“23.0.3”并将
targetSdkVersion
设置为23,但失败的原因是相同的错误。
compiledSdkVersion
应该是23
buildToolsVersion
至少在最新版本中设置为23.0.3。此外,这不会修复编译错误。您需要确保应用程序没有使用仅在不向后兼容的较新SDK版本中可用的功能
android:paddingStart
等作为示例添加到API 17中,因此如果不指定较旧的方法(
android:paddingLeft
等),它们将无法在较旧的版本中工作。为什么如此复杂?在低于默认值的平台上运行应用程序不是一项常规任务吗?不幸的是,我在这方面没有太多经验,因此我无法修复它,我只是不知道在哪里检查和更改这些设置…对于为什么它不会以
N
作为目标运行以及以最小SDK设置为16的编译SDK版本,请参见。您应该能够将
compiledSdkVersion
targetSdkVersion
设置为23,并将
minSdkVersion
设置为16。@GeorgeMulligan,谢谢您的评论。嗯,我尝试将
compiledSdkVersion
设置为“23.0.3”并将
targetSdkVersion
设置为23,但失败的原因是相同的错误。
compiledSdkVersion
应该是23
buildToolsVersion
至少在最新版本中设置为23.0.3。此外,这不会修复编译错误。您需要确保应用程序没有使用仅在不向后兼容的较新SDK版本中可用的功能
android:paddingStart
等作为示例添加到API 17中,因此如果不指定较旧的方法(
android:paddingLeft
等),它们将无法在较旧的版本中工作。为什么如此复杂?在低于默认值的平台上运行应用程序不是一项常规任务吗?不幸的是,我在这方面没有经验,因此我无法修复它,我只是不知道在哪里检查和更改这些设置。。。