5
我已經將反射框架添加到了我的android項目中。但是它沒有被添加到類路徑中。 Android Studio建議我需要手動添加它,但是由於gradle無法構建它,所以我無法啓動我的應用程序。未將Gradle編譯依賴關係添加到類路徑中
這裏是我的應用程序模塊的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my.package"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':offlinetasks')
compile project(':tasks')
compile project(':models')
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'org.roboguice:roboguice:3.0.1'
provided 'org.roboguice:roboblender:3.0.1'
compile 'com.android.support:support-annotations:22.1.1'
compile('org.reflections:reflections:0.9.10') {
exclude module: 'xml-apis'
exclude module: 'annotations'
}
testCompile 'junit:junit:4.12'
testCompile('com.squareup.assertj:assertj-android:1.0.0') {
exclude module: 'support-annotations'
}
}
當我構建應用程序,並嘗試使用它,我不能自動導入思考類。 Android Studio建議的唯一方法是手動添加反射框架。
我已經把它添加到類路徑後手動我可以導入類。然而,當我試圖啓動它,我得到以下錯誤:
tasks:compileReleaseJava
/.../TaskFactory.java:8: error: package org.reflections does not exist
import org.reflections.Reflections;
有誰知道爲什麼會這樣?
編輯: 我的項目的build.gradle看起來是這樣的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
我已經將root build.gradle添加到了我的問題中。 – mvieghofer
這是否回答您的問題? – mvieghofer
是的,根項目配置提供了必要的信息。我試圖模仿你的情況。目前看起來'org.reflections:reflections:0.9.10'在添加的存儲庫中都不可用,但我需要檢查它。 –