我正在尝试克隆这个twitter 工具包存储库,并想在 android studio 中打开示例应用程序。然后我得到这个 gradle 同步错误:
Error(3,0) Could not get unknown property 'dependency' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
出现此错误的 gradle 文件:
buildscript {
dependencies {
classpath dependency.spoonGradlePlugin
}
}
//Load API Key information in from property file
Properties props = new Properties()
try {
props.load(file('twitter.properties').newDataInputStream())
} catch (Exception ex) {
// throw new GradleException("Missing twitter.properties, check the twitter.properties.sample file.");
}
apply plugin: 'com.android.application'
apply plugin: 'spoon'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.example.app.twitter"
versionCode 1
versionName "1.0"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
testInstrumentationRunner "com.example.app.SpoonInstrumentationTestRunner"
}
buildTypes {
debug {
resValue "string", "com.twitter.sdk.android.CONSUMER_KEY", "\"${props.getProperty("twitterConsumerKey")}\""
resValue "string", "com.twitter.sdk.android.CONSUMER_SECRET", "\"${props.getProperty("twitterConsumerSecret")}\""
resValue "bool", "com.twitter.sdk.android.TRACE_ENABLED", "true"
resValue "bool", "com.twitter.sdk.android.COLLECT_IDENTIFIERS_ENABLED", "true"
buildConfigField "String", "MOPUB_AD_UNIT_ID", "\"${props.getProperty("mopubAdUnitId")}\""
}
release {
resValue "string", "com.twitter.sdk.android.CONSUMER_KEY", "\"${props.getProperty("twitterConsumerKey")}\""
resValue "string", "com.twitter.sdk.android.CONSUMER_SECRET", "\"${props.getProperty("twitterConsumerSecret")}\""
resValue "bool", "com.twitter.sdk.android.TRACE_ENABLED", "false"
resValue "bool", "com.twitter.sdk.android.COLLECT_IDENTIFIERS_ENABLED", "true"
buildConfigField "String", "MOPUB_AD_UNIT_ID", "\"${props.getProperty("mopubAdUnitId")}\""
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
spoon {
if (project.hasProperty('spoonClassName')) {
className = project.spoonClassName
}
}
lintOptions {
warningsAsErrors true
}
compileOptions {
sourceCompatibility rootProject.sourceCompatibilityVersion
targetCompatibility rootProject.targetCompatibilityVersion
}
}
dependencies {
compile project(':twitter')
compile project(':twitter-mopub')
compile dependency.appCompat
compile dependency.design
compile dependency.okHttpInterceptor
debugCompile dependency.leakCanary
releaseCompile dependency.leakCanaryNoOp
androidTestCompile dependency.spoon
androidTestCompile dependency.espresso
androidTestCompile dependency.androidTestingSupport
}
我发现依赖格式看起来不错。如何消除此错误并运行示例应用程序?