Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve class in build.gradle using Android Studio 0.60/Gradle 0.11

Established app working fine using Android Studio 0.5.9/ Gradle 0.9 but upgrading to Android Studio 0.6.0/ Gradle 0.11 causes the error below.

Somehow Studio seems to have lost the ability to resolve the android tools import at the top of the build.gradle file.

Anyone got any ideas on how to solve this?

build file 'Users/[me]/Repositories/[project]/[module]/build.gradle': 1: unable to resolve class com.android.builder.DefaultManifestParser @ line 1, column 1.
import com.android.builder.DefaultManifestParser 
1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:858)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:548)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileScript(DefaultScriptCompilationHandler.java:115)
... 77 more
2014-06-09 10:15:28,537 [  92905]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/[me]/Repositories/[project]'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.12-all.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)

[project]/[module]/build.gradle

import com.android.builder.DefaultManifestParser

apply plugin: 'android-sdk-manager'
apply plugin: 'android'

android {

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            res.srcDirs = ['src/main/res']
        }
        debug {
            res.srcDirs = ['src/debug/res']
        }
        release {
            res.srcDirs = ['src/release/res']
        }
    }

    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    signingConfigs {
        release
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
            applicationVariants.all { variant ->
                def file = variant.outputFile
                def manifestParser = new DefaultManifestParser()
                def wmgVersionCode = manifestParser.getVersionCode(android.sourceSets.main.manifest.srcFile)
                println wmgVersionCode
                variant.outputFile = new File(file.parent, file.name.replace("-release.apk", "_" + wmgVersionCode + ".apk"))
            }
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}



def Properties props = new Properties()
def propFile = file('signing.properties')
if (propFile.canRead()){
    props.load(new FileInputStream(propFile))

    if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
            props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {

        println 'RELEASE BUILD SIGNING'

        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
    } else {
        println 'RELEASE BUILD NOT FOUND SIGNING PROPERTIES'

        android.buildTypes.release.signingConfig = null
    }
}else {
    println 'RELEASE BUILD NOT FOUND SIGNING FILE'
    android.buildTypes.release.signingConfig = null
}

repositories {
    maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

dependencies {
    compile 'com.github.gabrielemariotti.changeloglib:library:1.4.+'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.squareup.okhttp:okhttp:1.5.+'
    compile 'com.octo.android.robospice:robospice:1.4.11'
    compile 'com.octo.android.robospice:robospice-cache:1.4.11'
    compile 'com.octo.android.robospice:robospice-retrofit:1.4.11'
    compile 'com.commonsware.cwac:security:0.1.+'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile 'com.android.support:support-v4:19.+'
    compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1+'
    compile 'de.greenrobot:eventbus:2.2.1+'
    compile project(':captureActivity')
    compile ('de.keyboardsurfer.android.widget:crouton:1.8.+') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    compile files('libs/CWAC-LoaderEx.jar')
}
like image 746
saywhatnow Avatar asked Jun 09 '14 03:06

saywhatnow


1 Answers

Been having the same problem as you all day, turns out it just moved package!

Change:

import com.android.builder.DefaultManifestParser

To:

import com.android.builder.core.DefaultManifestParser

Works for me now! :)

like image 173
Charlie Avatar answered Nov 13 '22 19:11

Charlie