我的Crashlytics正在我的应用程序中工作。
我在我的应用程序中添加了一个名为'engine-module'的Android模块,它有自己的Gradle依赖项。
我不知道如何正确导入Crashlytics依赖项,我只是收到以下错误:
错误:(31,13)无法解决: com.crashlytics.sdk.android:crashlytics:2.6.5
我想要实现的是能够从'engine-module'中的类中访问'Crashlytics',例如:
Crashlytics.setUserName("temp user name");
这可能吗?如果是这样,怎么能实现呢?
项目:build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
apply from: '../jacoco.gradle'
}
应用/的build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.neenbedankt.android-apt'
/**
* Default values for configuration options
*/
def suffixDefault = ""
def versionCodeDefault = 1
def versionNameDefault = "developerBuilt"
/**
* Android-specific configuration
*/
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.flowmellow.projectx
minSdkVersion 16
targetSdkVersion 25
versionCode project.getProperties().get('versionCode') ? project.getProperties().get('versionCode').toInteger() : versionCodeDefault
versionName project.getProperties().get('versionName') ? project.getProperties().get('versionName') : versionNameDefault
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
// Configurable options
applicationIdSuffix project.getProperties().get('appIdSuffix', suffixDefault) + ".debug"
// Common options
testCoverageEnabled true
}
release {
// Configurable options
applicationIdSuffix project.getProperties().get('appIdSuffix', suffixDefault)
// Common options
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
/**
* Dependencies
*/
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
//Dependency injection
apt 'com.google.dagger:dagger-compiler:2.7'
compile 'com.google.dagger:dagger:2.7'
provided 'javax.annotation:jsr250-api:1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'org.robolectric:robolectric:3.1.2'
testCompile 'org.hamcrest:hamcrest-library:1.1'
compile 'com.android.support.constraint:constraint-layout:+'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
compile project(path: ':engine-module')
}
模块:engine-module / build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:25.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'org.robolectric:robolectric:3.1.2'
compile 'com.crashlytics.sdk.android:crashlytics:2.6.5'
}
解决:
项目:build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
apply from: '../jacoco.gradle'
}
模块:engine-module / build.gradle
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:25.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'org.robolectric:robolectric:3.1.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
}
答案 0 :(得分:1)
您没有为self.tableView
模块定义任何存储库,这意味着它无法解析相关的依赖项。
通常人们通过将以下代码添加到根cell
engine-module
这使得这些存储库可用于所有子项目。