无法使用Android Studio

时间:2015-04-22 12:25:59

标签: android-studio

我将我的Android应用程序从eclipse迁移到Android Studio。在这次“迁移”期间,我决定将我的项目拆分为4个模块:GUI模块,引擎模块,公共模块和资源模块。

The problem is that I cannot include v4 or v7 libs... It does not recognize the import:"import android.support.v4."

以下是分数:

1.Genral Gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

1.Gradle for GUI模块(主模块):

apply plugin: 'com.android.application'

dependencies {
    compile 'com.android.support:support-v4:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile project(':audiorecengine')
    compile 'com.google.android.gms:play-services:7.0.0'
}


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.audioRec"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 73
        versionName "4.0.4"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        lite {
            applicationId = "com.audioRec"
            versionCode 73
            versionName "4.0.4"
        }
        pro {
            applicationId = "com.audioRec.pro"
            versionCode 13
            versionName "3.0.3"
        }
    }
}
  1. Gradle for engine module:

    apply plugin: 'com.android.library'
    
    android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"
    
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
       compile fileTree(dir: 'libs', include: ['*.jar'])
       compile 'com.android.support:appcompat-v7:22.0.0'
       compile project(':audioreccommons')
    }
    

1 个答案:

答案 0 :(得分:0)

问题似乎是由已包含v4支持库的GooglePlayService lib引起的。解决方案是在编译playServices时排除support-v4。

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':audiorecengine')
    compile ('com.google.android.gms:play-services:7.0.0'){
        exclude module: 'support-v4'
    }
}

我还从gradle依赖项中删除了v4,因为它已经包含在v7支持lib