Android Studio 无法启动应用程序

标签 android android-studio crash

我从 eclipse 切换到 android studio。我创建了一个空白应用程序用于测试目的,并且能够正确启动。然而,在添加了一些简单的代码后,我不再开始。我收到的错误消息是:

Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.

Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.

...

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/Tom/Java/Android/android_sdk_4.2/build-tools/19.1.0/aapt package -f --no-crunch -I /Users/Tom/Java/Android/android_sdk_4.2/platforms/android-17/android.jar -M /Users/Tom/Programming/ToyApp/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/Tom/Programming/ToyApp/app/build/intermediates/res/debug -A /Users/Tom/Programming/ToyApp/app/build/intermediates/assets/debug -m -J /Users/Tom/Programming/ToyApp/app/build/generated/source/r/debug -F /Users/Tom/Programming/ToyApp/app/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package app.beziehungen -0 apk --output-text-symbols /Users/Tom/Programming/ToyApp/app/build/intermediates/symbols/debug
  Error Code:
    1
  Output:
    /Users/Tom/Programming/ToyApp/app/build/intermediates/res/debug/values-v21/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
    /Users/Tom/Programming/ToyApp/app/build/intermediates/res/debug/values-v21/values.xml:6: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
    /Users/Tom/Programming/ToyApp/app/build/intermediates/res/debug/values-v21/values.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
    /Users/Tom/Programming/ToyApp/app/build/intermediates/res/debug/values-v21/values.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
....

那么这里发生了什么。代码绝对正确!

最佳答案

确保您已通过 SDK-Manager 下载最新的附加功能以及 Android 5.0 SDK。

并在 build.gradle 文件中将 compileSdkVersion 设置为 21。您可能还想将 targetSdkVersion 更改为 21。

android {
    //...
    compileSdkVersion 21

    defaultConfig {
        targetSdkVersion 21
    }
    //...
}

关于Android Studio 无法启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28221532/

相关文章:

android - 使用 Intent.ACTION_SEND_MULTIPLE 通过蓝牙发送多个文件

java - 尝试生成签名的 APK 时出现 TaskExecutionException

java - 使用音轨 android studio 改变音调

android - gradle如何解决Retrofit等不同版本的重复依赖?

android - Cordova android 模拟器 "cannot read property ' 替换“未定义”

java - 比例变化后重绘 GraphView

c++ - 使用 QFileDialog 后程序在几秒钟后崩溃

java - 无法从静态内容引用非静态方法 checkWriteStoragePermission()

ionic-framework - 获取应用程序崩溃日志

crash - IOS 8 在方向更改时崩溃