首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Git子模块导致失败[INSTALL_FAILED_OLDER_SDK] Android 21

Git子模块导致失败[INSTALL_FAILED_OLDER_SDK] Android 21
EN

Stack Overflow用户
提问于 2014-11-02 17:46:09
回答 1查看 289关注 0票数 0

我正在开发一个应用程序,并尝试使用新的材料设计,又名sdk版本21。我的一切正常工作,然后想在fab (浮动动作按钮)使用这个图书馆

我将这个库添加为子模块,使用

代码语言:javascript
复制
git submodule add https://github.com/shamanland/floating-action-button

而在C:\Users\USER\AndroidStudioProjects\ProjectName下

我的文件结构如下所示

代码语言:javascript
复制
ProjectName
    app
    floating-action-button

问题之前一切都很好,我能够构建和运行该项目。但是,自从添加了这个子模块之后,当尝试运行它时,我就会得到错误。

代码语言:javascript
复制
Failure [INSTALL_FAILED_OLDER_SDK]

所以我想这和子模块有关,但我不知道怎么做。

app/build.gradle

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.0.2'

    defaultConfig {
        applicationId "com.mayuonline.ribbit"
        minSdkVersion 21
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:palette-v7:+'
}

app/AndroidManifest.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="resume.kelseyhrubes">

    <uses-sdk tools:node="replace" />

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

f-a-b/build.gradle

代码语言:javascript
复制
buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
        classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0'
    }
}

def isSnapshot() {
    return VERSION_NAME.contains('SNAPSHOT')
}

def gradleMvnPush = new File(buildDir, 'gradle-mvn-push.gradle')
if (!gradleMvnPush.exists()) {
    buildDir.mkdirs()
    ant.get(src: GRADLE_MVN_PUSH, dest: gradleMvnPush)
}

setProperty('GRADLE_MVN_PUSH', gradleMvnPush)

subprojects {
    group GROUP
    version VERSION_NAME

    apply plugin: 'android-sdk-manager'

    if (name.startsWith('lib')) {
        apply plugin: 'com.android.library'
    } else {
        apply plugin: 'com.android.application'
    }

    android {
        compileSdkVersion COMPILE_SDK_VERSION as int
        buildToolsVersion BUILD_TOOLS_VERSION

        defaultConfig {
            minSdkVersion MIN_SDK_VERSION as int
            targetSdkVersion TARGET_SDK_VERSION as int
            versionCode 1
            versionName '1.0'

            // workaround for https://code.google.com/p/android/issues/detail?id=52962
            buildConfigField 'boolean', 'SNAPSHOT', isSnapshot().toString()
        }

        lintOptions {
            abortOnError false
        }
    }

    repositories {
        mavenLocal()
        mavenCentral()
    }

    if (isSnapshot()) {
        apply plugin: 'robolectric'

        dependencies {
            // NOTE workaround for sdkmanager plugin
            compile 'com.android.support:support-v4:19.0.1'

            androidTestCompile 'junit:junit:4.10'
            androidTestCompile 'org.robolectric:robolectric:2.3'
            androidTestCompile 'com.squareup:fest-android:1.0.8'
        }
    }
}

f-a-b/AndroidManifest.xml (可能是这里的一条线索,我试图在Android变成红色的区域进行大胆尝试)

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" **http://schemas.android.com/apk/res/android** "
          package="com.shamanland.fab.example">

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

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=" **.ExampleDetailsActivity** "/>
    </application>
</manifest>

我强烈怀疑子模块添加的不正确。

我真正想要的只是在我的应用程序中使用一个fab,如果有人能帮我找出可能出了什么问题,添加子模块,或者使用我的build.gradle,这将是非常感谢的!

EN

回答 1

Stack Overflow用户

发布于 2014-11-03 04:55:39

此错误通常是通过将使用"compileSdkVersion n“构建的APK部署到API级别小于"n”的设备或模拟器中引起的。您的模拟器是否处于正确的API级别?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26702376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档