Проблемы с зависимостью от проекта Room не прекращают строить застрявшую на «Task: app: mergeExtDexDebug» любую помощь, указатели? Gradle? - PullRequest
0 голосов
/ 25 апреля 2020

Во-первых, я попробовал различные альтернативы для библиотеки комнат, самая новая из которых - 2.2.5, единственная, которая фактически запускает мяч, и приложение строит, однако при загрузке я получаю крэ sh, который регистрирует:

java.lang.RuntimeException: cannot find implementation for com.githubbrowser.db.GithubDb. GithubDb_Impl does not exist
        at com.githubbrowser.viewmodel.GithubViewModelFactory.create(GithubViewModelFactory.java:42)

Которые приводят меня через множество постов, где я думаю, что это была проблема с моей viewModel или чем-то с моей стороны.

Однако теперь у меня есть догадка, что это не так и что где-то в моем gradle есть проблема.

У меня есть следующие зависимости:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    dataBinding {
        enabled = true
    }

    defaultConfig {
        applicationId "com.githubbrowser"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "room.schemaLocation":"$projectDir/schemas".toString(),
                        "room.incremental":"true",
                        "room.expandProjection":"true"]
            }
        }
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }


}

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

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'

    implementation "androidx.lifecycle:lifecycle-runtime:2.2.0"
    implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation  "com.squareup.retrofit2:converter-gson:2.5.0"


    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    implementation 'com.google.dagger:dagger-android:2.23.2'
    implementation 'com.google.dagger:dagger-android-support:2.23.2' // if you use the support libraries
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.23.2'

    implementation 'com.jakewharton.timber:timber:4.7.1'

    implementation 'com.google.dagger:dagger:2.23.2'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.23.2'


    implementation 'androidx.room:room-runtime:2.2.5'




}

, и мои журналы начинают кричать мне об этой строке кода:

Это часть моего ViewModelFactory класс, в котором возникает ошибка времени выполнения ...

@Singleton
public class GithubViewModelFactory implements ViewModelProvider.Factory {

private final Map<Class<? extends ViewModel>, Provider<ViewModel>> creators;

@Inject
public GithubViewModelFactory(Map<Class<? extends ViewModel>, Provider<ViewModel>> creators) {
    this.creators = creators;
}

@SuppressWarnings("unchecked")
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
    Provider<? extends ViewModel> creator = creators.get(modelClass);
    if(creator == null) {
        for(Map.Entry<Class<? extends ViewModel>, Provider<ViewModel>> entry : creators.entrySet()) {
            if(modelClass.isAssignableFrom(entry.getKey())) {
                creator = entry.getValue();
                break;
            }
        }
    }
    if(creator == null) {
        throw new IllegalArgumentException("UNKNOWN model class....");
    }
    try {
        return (T) creator.get();
    } catch (Exception e) {
        throw new RuntimeException(e);  <----------------------------------H E R E !!!

    }
}

}

Это другой мой файл Gradle

buildscript {

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://kotlin.bintray.com/kotlinx/" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Любая помощь будет принята с благодарностью. Приложение встроено в Java.

Всего наилучшего.

...