无法使用Android Studio 0.60 / Gradle 0.11解析build.gradle中的类

前端之家收集整理的这篇文章主要介绍了无法使用Android Studio 0.60 / Gradle 0.11解析build.gradle中的类前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用 Android Studio 0.5.9 / Gradle 0.9建立应用程序正常工作,但升级到Android Studio 0.6.0 / Gradle 0.11会导致以下错误.

不知何故,Studio似乎已经失去了解析build.gradle文件顶部的android工具导入的能力.

任何人对如何解决这个问题都有任何想法?

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)

[项目] / [模块] /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')
}

解决方法

和你一整天都有同样的问题,原来它只是搬了包!

更改:

import com.android.builder.DefaultManifestParser

至:

import com.android.builder.core.DefaultManifestParser

现在适合我! 原文链接:https://www.f2er.com/android/316524.html

猜你在找的Android相关文章