2017-10-31 5 views
0

から参照を解決することはできません。 Deviceには、アプリケーション参照を含むNetworkComponentクラスが含まれています。具体的には、Gradleでは、私は、以下のモジュールでプロジェクトを持っている別のモジュール

package com.some.package.ui.login; 

import android.content.Intent 
import android.os.Bundle 
import android.support.v7.app.AppCompatActivity 
import com.some.package.R 
import com.some.package.device.network.NetworkComponent 
import com.some.package.ui.terms.TermsActivity 

class LoginActivity : AppCompatActivity(), 
     LoginViewModel.Navigator { 

    val loginViewModel by lazy { LoginViewModel(this, NetworkComponent()) } 

すべてがAndroidスタジオで問題なく解決します。私はプロジェクトをビルドしようとすると、まだ、私はビルドエラーが発生します。

e: /Users/android/some-app-android/app/src/main/kotlin/com/some/package/ui/login/LoginActivity.kt: (7, 27): Unresolved reference: network 
e: /Users/android/some-app-android/app/src/main/kotlin/com/some/package/ui/login/LoginActivity.kt: (13, 55): Unresolved reference: NetworkComponent 
[KOTLIN] deleting /Users/android/some-app-android/app/build/tmp/kotlin-classes/debug on error 
[KOTLIN] deleting /Users/android/some-app-android/app/build/tmp/kotlin-classes/debug on error 
:app:compileDebugKotlin FAILED 

これはNetworkComponentは、次のようになります。ここでは

package com.some.package.device.network 

import com.some.package.domain.datasources.CodeValidator 
import retrofit2.Retrofit 


class NetworkComponent : CodeValidator { 

    val codeValidator: CodeValidatorApi 

    init { 
     val retrofit = Retrofit.Builder() 
       .baseUrl("www.test.com") 
       .build() 

     codeValidator = retrofit.create(CodeValidatorApi::class.java) 
    } 

    override fun validate(code: String) = codeValidator.validate(code) 
} 

ビルドファイルは、以下のとおりです。

トップ:

buildscript { 
    ext.kotlin_version = '1.1.51' 
    ext.android_tools = '3.0.0' 
    repositories { 
     google() 
     jcenter() 
    } 

    dependencies { 
     classpath "com.android.tools.build:gradle:$android_tools" 
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
    } 
} 

allprojects { 
    repositories { 
     google() 
     jcenter() 
     mavenCentral() 
    } 
} 

アプリ:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
} 

apply plugin: 'com.android.application' 
apply plugin: 'kotlin-android' 
apply plugin: 'kotlin-kapt' 

//apply plugin: 'io.fabric' 

// Manifest version information 
def versionMajor = 0 
def versionMinor = 0 
def versionPatch = 1 

android { 
    compileSdkVersion 27 

    defaultConfig { 
     applicationId "com.some.package" 
     minSdkVersion 21 
     targetSdkVersion 27 
     versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch 
     versionName "${versionMajor}.${versionMinor}.${versionPatch}" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 

    buildTypes { 
     debug { 
//   applicationIdSuffix '.debug' 
      resValue "string", "application_name", "TEST APP Debug" 
      debuggable true 
     } 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      resValue "string", "application_name", "TEST APP" 
     } 
    } 

    dataBinding { 
     enabled = true 
    } 

    sourceSets { 
     main.java.srcDirs += 'src/main/kotlin' 
     debug.java.srcDirs += 'src/debug/kotlin' 
    } 

    packagingOptions { 
     exclude 'META-INF/ASL2.0' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/services/javax.annotation.processing.Processor' // butterknife 
    } 
} 

repositories { 
    maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } 
} 

dependencies { 
    implementation project(':device') 
    implementation project(':data') 
    implementation project(':domain') 

    implementation fileTree(include: ['*.jar'], dir: 'libs') 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
    implementation 'com.android.support:support-v4:27.0.0' 
    implementation 'com.android.support:appcompat-v7:27.0.0' 
    implementation 'com.android.support:design:27.0.0' 
    implementation 'com.android.support:support-annotations:27.0.0' 
    kapt "com.android.databinding:compiler:$android_tools" 

    // Logging 
    implementation 'com.jakewharton.timber:timber:4.5.1' 

    // Unit tests 
    testImplementation 'junit:junit:4.12' 
// testImplementation 'org.robolectric:robolectric:3.0' 
    testImplementation 'org.mockito:mockito-core:2.11.0' 
// testImplementation 'joda-time:joda-time:2.9.4' 

// debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1' 
// releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 
// testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 



    implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0' 

    debugImplementation 'com.facebook.stetho:stetho:1.4.1' 
    debugImplementation 'com.uphyca:stetho_realm:2.0.0' 
// implementation('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
//  transitive = true; 
// } 
} 

デバイス:

apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 27 

    defaultConfig { 
     minSdkVersion 21 
     targetSdkVersion 27 
     versionCode 1 
     versionName "1.0" 

     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    sourceSets { 
     main.java.srcDirs += 'src/main/kotlin' 
    } 
} 

dependencies { 
    implementation fileTree(dir: 'libs', include: ['*.jar']) 
    implementation project(':domain') 

    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    implementation 'com.android.support:appcompat-v7:27.0.0' 

    implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0' 
    implementation "com.squareup.retrofit2:retrofit:2.3.0" 
    implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0" 

    testImplementation 'junit:junit:4.12' 
} 

は、私はこれが起こることができるか、非常にわかりません。私はgradleプラグインを2.3.3にダウングレードしようとしましたが、運はありません。

アイデア?

+0

ため、この答えのおかげで 'NetworkComponent'が'実装しているという事実によって何とかが生じる場合がございますCodeValidator'。 'CodeValidator'は公開されていますか? – Egor

+0

@Egorはい。それは別のモジュールにあります。私はCodeValidatorをコメントアウトして、NetworkComponentは実装していませんが、結果は同じです。 – Vas

答えて

関連する問題