Tôi đã thêm khung phản chiếu vào dự án Android của mình. Tuy nhiên nó không được thêm vào classpath. Android Studio gợi ý rằng tôi cần thêm nó theo cách thủ công, tuy nhiên tôi không thể khởi động ứng dụng của mình vì gradle không thể xây dựng ứng dụng đó.Phụ thuộc biên dịch Gradle không được thêm vào classpath
Đây là build.gradle của module ứng dụng của tôi:
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'
}
}
Khi tôi xây dựng các ứng dụng và cố gắng sử dụng nó, tôi không thể import lớp Reflections tự động. Điều duy nhất mà Android Studio đề xuất là thêm khung phản chiếu theo cách thủ công.
Sau khi tôi đã thêm nó vào classpath tay tôi có thể nhập khẩu các lớp. Tuy nhiên, khi tôi cố bắt đầu, tôi nhận được lỗi sau:
tasks:compileReleaseJava
/.../TaskFactory.java:8: error: package org.reflections does not exist
import org.reflections.Reflections;
Có ai biết tại sao điều này xảy ra không?
Edit: Dự án của tôi build.gradle trông như thế này:
// 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()
}
}
Tôi đã thêm root build.gradle vào câu hỏi của mình. – mvieghofer
điều này có trả lời câu hỏi của bạn không? – mvieghofer
Có, cấu hình dự án gốc cung cấp thông tin cần thiết. Tôi đã cố gắng để thi đua tình hình của bạn. Hiện tại, xem 'org.reflections: reflections: 0.9.10' không khả dụng trong cả hai kho được thêm, nhưng tôi cần kiểm tra nó. –