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

时间:2016-04-15 21:51:11

标签: android android-studio

不幸的是,我在Android开发方面没有经验。我为我的Mac下载了Android Studio,安装了java并完成了来自developers.android.com(http://developer.android.com/training/basics/firstapp/index.htmlhttp://developer.android.com/training/basics/firstapp/running-app.html)的官方文档中描述的所有内容。

然后我尝试创建第一个基本项目并在我的三星Galaxy S2上运行它。不幸的是我无法运行它,因为Android Studio抱怨我的Galaxy S2支持API 16,而项目需要API 23(midSdk(API 23, N, preview) != 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,但由于某种原因它不起作用。

感谢。

0 个答案:

没有答案