Bir Android projesinde Kotlin ile Dagger 2'yi test ediyorum. Android Clean Architecture repo'dan ilham aldım. Gradle derlememde iki tane modül var, biri "app", diğeri "module". Modül bir sınıf arama Modeli içerir. Benim app gradle modülünde bir Model sağlayıcı ile "DaggerModule" adlı bir hançer modülü oluşturdu.Çözülmemiş referans hançer 2 + kotlin + android gradyanı
Ben "app" modül her şeyin içine "modül" modülünden Modeli sınıfını hareketli deneyinDaggerModule.kt: (3, 57): Unresolved reference: Model
DaggerModule.kt: (9, 34): Unresolved reference: Model
DaggerModule.kt: (9, 42): Unresolved reference: Model
hata w/o derler: Ben projeyi inşa etmeye çalıştığımda, derleme hataları olsun. Aptalca bir şey yapıp yapmadığımı ya da bir yerde bir hata yapmam gerekip gerekmediğini anlamaya çalışıyorum. Burada referans sorunlu dosyaların parçacıkları için
:
----
app/build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.1218'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
repositories {
jcenter()
mavenCentral()
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.github.app.kotlin_unresolved_reference.app"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':module')
compile 'com.android.support:appcompat-v7:22.2.1'
kapt "com.google.dagger:dagger-compiler:2.0.1"
compile "com.google.dagger:dagger:2.0.1"
compile "javax.annotation:javax.annotation-api:1.2"
compile "org.jetbrains.kotlin:kotlin-stdlib:0.12.1218"
}
---
module/build.gradle
apply plugin: 'java'
//noinspection GroovyUnusedAssignment
sourceCompatibility = 1.7
//noinspection GroovyUnusedAssignment
targetCompatibility = 1.7
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
dependencies {
provided "com.google.dagger:dagger-compiler:2.0.1"
compile "com.google.dagger:dagger:2.0.1"
compile "javax.annotation:javax.annotation-api:1.2"
compile "org.jetbrains.kotlin:kotlin-stdlib:0.12.1218"
}
---
DaggerModule.kt
Module
public class DaggerModule {
Provides fun provideModel(): Model = Model()
}
----
Model.kt
public class Model { }
UYARI: Bu e Hançer 2 sürüş ilk kez testtir ve bir gradle newb. Örnek proje, sorunu görüntülemek için bulabileceğim minimum koddur. Çok şey yapmasını beklemiyorum: D.
, ** settings.gradle ** içinde bulunan modülünüzdür? – Lamorak
Modül, grad ayarlarında bulunur. – donaldlittlpie