gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:23:19 24 4
gpt4 key购买 nike

已建立的应用程序使用 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

现在对我有用! :)

关于android - 无法使用 Android Studio 0.60/Gradle 0.11 解析 build.gradle 中的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24113253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com