错误:(66,56)错误:找不到符号变量M.

时间:2018-01-31 23:02:33

标签: android build.gradle maven-plugin android-studio-3.0

我有一个通过maven使用库依赖的示例应用程序。我收到如下编译错误:

Error:(66, 56) error: cannot find symbol variable M

实际上是代码中的以下行

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        //something
    }

以下是app模块的build.gradle:

 apply plugin: 'com.android.application'

    android {
     compileSdkVersion 27

    defaultConfig {
        applicationId "com.lokesh.videomoduletest"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    dataBinding {
        enabled = true
        version = '2.3.3'
    }

    lintOptions {
        abortOnError false
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
     }
    }

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.0.2'
    api "com.android.support:support-v4:27.0.2"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation('com.libexp:a-gr:0.0.3@aar') {
        transitive = true
    }
    }

这是库模块的build.gradle

 android.testOptions.unitTests.all {
    // Configure whether failing tests should fail the build
    ignoreFailures false

    testLogging {
        events "passed", "skipped", "failed", "standardOut", "standardError"
    }
    jacoco {
        includeNoLocationClasses = true
    }

    jvmArgs '-noverify'
    }

    android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            testCoverageEnabled true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            testCoverageEnabled false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
    }

     ext {
      supportLibraryVersion = '27.0.2'
      mockitoVersion = '2.8.47'
      timberVersion = '4.6.0'
      }

     dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testImplementation 'junit:junit:4.12'
    testImplementation "org.robolectric:robolectric:3.4"
    testImplementation "org.mockito:mockito-core:$mockitoVersion"

    androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
    androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"

    implementation 'com.google.code.gson:gson:2.8.2'
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"

    //RX
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'

    //timber
    implementation "com.jakewharton.timber:timber:$timberVersion"

    // On-device logging
    implementation 'org.slf4j:slf4j-api:1.7.21'
    implementation 'com.github.tony19:logback-android-core:1.1.1-6'
    implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
        // workaround issue #73
        exclude group: 'com.google.android', module: 'android'
    }

    //apache commons
    implementation 'org.apache.commons:commons-lang3:3.6'
    }

我找到了this。但它对我不起作用,因为compileSdkVersion,targetSdkVersion在我的情况下是相同的,而且在Android Studio 3.0中buildToolsVersion是可选的

感谢。

0 个答案:

没有答案