我在Android Studio项目中添加了mapsforge版本0.3.0和0.3.1 jar文件。
这是我的build.gradle文件
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/resources']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
}
}
dependencies {
compile ('com.android.support:support-v4:13.0.+')
compile files ('libs/mapsforge-map-0.3.0-SNAPSHOT-jar-with-dependencies.jar','libs/mapsforge-map-0.3.1-SNAPSHOT-jar-with-dependencies.jar')
}
我在gradle.properties
中有这个#Wed Jun 11 16:12:51 PHT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
当我同步gradle时:
~~~~~~~~显示此错误~~~~~~~
Error:(4, 0) Build script error, unsupported Gradle DSL method found: 'compile()'!**
Possible causes could be:
- you are using Gradle version where the method is absent (<a href="open_gradle_settings">Fix Gradle settings</a>)
- you didn't apply Gradle plugin which provides the method (<a href="apply_gradle_plugin">Apply Gradle plugin</a>)
- or there is a mistake in a build script (<a href="goto_source">Goto source</a>)
请帮助我在这里呆了两天。
答案 0 :(得分:0)
将您的jar文件放在项目浏览器项目的libs文件夹中,它应该在项目名称/ app / libs /下,如果它不存在则创建它。
然后只需将此catch全部放入build.gradle。
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
您也可以尝试更新为gradle 1.12更改
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
到
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip