【问题标题】:How to run an app on Android L OR on 4.4 with Android Studio?如何使用 Android Studio 在 Android L 或 4.4 上运行应用程序?
【发布时间】:2014-08-29 20:23:25
【问题描述】:

我开始使用 Android 开发并尝试在 Android L 上使用测试应用。

我希望能够在 Android L 模拟器上加载材料设计主题,并在我的 Android 4.4 模拟器上加载标准全息主题。我真的无法让它运行。

当我尝试运行应用程序时,我收到了这个错误:

Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.

我的gradle文件是这样的:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId 'com.blitzcomputerservices.equinehealth'
        versionCode 1
        versionName '1.0'
    }

    productFlavors {
        l {
            minSdkVersion 'android-L'
            targetSdkVersion 'L'
            compileSdkVersion 'android-L'
        }
        old {
            minSdkVersion 16
            targetSdkVersion 20
            //TODO comment second line if build is not compiles for "L"
            compileSdkVersion 20
        }
    }
}

dependencies {
    compile 'com.koushikdutta.ion:ion:1.1.5'
    compile 'com.soundcloud.android:android-crop:0.9.9@aar'
    /*lCompile 'com.android.support:appcompat-v7:21.+'
    oldCompile 'com.android.support:appcompat-v7:19.1.0'*/
}

还有清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.blitzcomputerservices.equinehealth">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.blitzcomputerservices.equinehealth.EquineHealthActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
        android:name="com.blitzcomputerservices.equinehealth.HorseDetails"
        android:parentActivityName="com.blitzcomputerservices.equinehealth.EquineHealthActivity"
        android:label="@string/title_activity_horse_details" >
    </activity>
    <activity android:name="com.soundcloud.android.crop.CropImageActivity" />
</application>

我有两个styles.xml 文件:

values 中的一个与:

    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

另一个在 values-v21 中:

   <!-- Base application theme. -->
   <style name="AppTheme" parent="android:Theme.Material">
       <!-- Customize your theme here. -->
   </style>

我做错了什么?

【问题讨论】:

    标签: android gradle android-gradle-plugin android-5.0-lollipop material-design


    【解决方案1】:

    另一个在 values-v21 中:

    L 预览版是 API 20,而不是 v21

    【讨论】:

    • 是错字还是我遗漏了什么?
    • 我刚刚尝试使用&lt;style name="AppTheme" parent="android:Theme.Material"&gt; &lt;!-- Customize your theme here. --&gt; &lt;/style&gt; 添加values-v20 文件夹并得到相同的错误.. 如果这就是你的意思。不知道我是不是看错了。
    • 您是否在安装了 L-preview 映像的设备上运行?即 Nexus 5 还是 Nexus 7?
    • @gmail 所有官方 android 示例的值都是 21。
    • @gmale 我正在使用模拟器,设置为运行 Android L。我也希望它在运行 4.4 的模拟器上运行(但显然没有 Android L 的“功能”,如材料设计,它应该只是回到 Holo 上。虽然它不会加载/编译。
    猜你喜欢
    • 2020-01-22
    • 1970-01-01
    • 1970-01-01
    • 2017-06-07
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 2016-05-15
    • 1970-01-01
    相关资源
    最近更新 更多