I have Crashlytics working in my App.
I've added an Android Module to my App named 'engine-module' which has it's own Gradle dependencies.
I don't know how to import the Crashlytics dependency correctly and I just get the following error:
Error:(31, 13) Failed to resolve:
com.crashlytics.sdk.android:crashlytics:2.6.5
What I want to achieve is being able to access 'Crashlytics' from a Class within the 'engine-module' for example:
Crashlytics.setUserName("temp user name");
Is this possible? If so, how can it be achieved?
Project: 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'
}
App/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')
}
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'
}
SOLVED:
Project: 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'
}
Module: 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;
}
}
You did not define any repositories for the engine-module module, this means it cannot resolve the associated dependencies.
Generally people define repositories for their entire project by adding the following code to the root build.gradle
subprojects {
repositories {
// Add repositories here
}
}
This makes these repositories available for all subprojects.
Related
I have taken code from Realm objectServerExample.
SyncCredentials creds = SyncCredentials.usernamePassword(username, password, createUser);
SyncUser.Callback<SyncUser> callback = new SyncUser.Callback<SyncUser>() {
#Override
public void onSuccess(#Nonnull SyncUser user) {
progressDialog.dismiss();
onLoginSuccess();
}
#Override
public void onError(#Nonnull ObjectServerError error) {
progressDialog.dismiss();
String errorMsg;
switch (error.getErrorCode()) {
case UNKNOWN_ACCOUNT:
errorMsg = "Account does not exists.";
break;
case INVALID_CREDENTIALS:
errorMsg = "User name and password does not match";
break;
default:
errorMsg = error.toString();
}
onLoginFailed(errorMsg);
}
};
It says Cannot resolve symbol SyncCredentials
io.realm.Realm class is working.
My project level gradle file
// 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:2.3.3'
classpath "io.realm:realm-gradle-plugin:3.7.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle (module:app)
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.amit.database"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// jackOptions {
// enabled true
// }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile "android.arch.lifecycle:runtime:1.0.0-alpha9"
compile "android.arch.lifecycle:extensions:1.0.0-alpha9"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9"
compile group: 'com.google.guava', name: 'guava', version: '22.0-android' // or 22.0-android for the Android flavor
compile 'com.android.support:design:25.3.1'
}
Main goal is to connect Android app with realm object server on aws-ec2. It is working and can be accessed from browser.
Add
realm {
syncEnabled = true
}
in gradle (module:app) to use realm sync feature
So final Gradle (module:app)
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.amit.database"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// jackOptions {
// enabled true
// }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
realm {
syncEnabled = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile "android.arch.lifecycle:runtime:1.0.0-alpha9"
compile "android.arch.lifecycle:extensions:1.0.0-alpha9"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9"
compile group: 'com.google.guava', name: 'guava', version: '22.0-android' // or 22.0-android for the Android flavor
compile 'com.android.support:design:25.3.1'
}
I have an old project, I import this project in my Android studio, i am getting this error.
Yes I searched for it from internet and i found many solutions for that,but non of them solved my issue.
Here is my build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is My module level build.gradle
here is my build.gradle which is under app>src>build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.pedrocarrillo.expensetracker"
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.2"
}
signingConfigs {
release {
def Properties localProps = new Properties()
localProps.load(new FileInputStream(file('../local.properties')))
storeFile file("tracker_expense.jks")
storePassword localProps["storePass"]
keyAlias localProps["alias"]
keyPassword localProps["pass"]
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:gridlayout-v7:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1#aar'
compile 'io.realm:realm-android:0.82.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
}
Try This : Project Level Gradle File...
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module Level Gradle File...
apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.pedrocarrillo.expensetracker"
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.2"
}
signingConfigs {
release {
def Properties localProps = new Properties()
localProps.load(new FileInputStream(file('../local.properties')))
storeFile file("tracker_expense.jks")
storePassword localProps["storePass"]
keyAlias localProps["alias"]
keyPassword localProps["pass"]
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:gridlayout-v7:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1#aar'
compile 'io.realm:realm-android:0.82.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
}
In your top-level file you have to remove this line:
apply plugin: 'com.android.application'
i'm trying to import clarifai api in my android project but it gives the following error :
Error:(28, 13) Failed to resolve: com.clarifai.clarifai-api2:android:2.0.2
project.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "ir.codinglab.objectrecognizer"
minSdkVersion 15
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'
}
}
lintOptions {
lintConfig rootProject.file('gradle/lint.xml')
}
}
dependencies {
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.clarifai.clarifai-api2:android:2.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}
I have to note that i don't have any problems with importing other libraries .
Thank you in advance.
the library you have entered is wrong. This is the correct one -
compile 'com.clarifai.clarifai-api2:core:2.2.3'
I am following some instructions, and I get this error.
Error:Could not find com.google.gms:google-services:3.0.0. Searched in the following locations: file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/google/gms/google-services/3.0.0/google-services-3.0.0.pom file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/google/gms/google-services/3.0.0/google-services-3.0.0.jar https://maven.fabric.io/public/com/google/gms/google-services/3.0.0/google-services-3.0.0.pom https://maven.fabric.io/public/com/google/gms/google-services/3.0.0/google-services-3.0.0.jar
Required by panic_android:app:unspecified
My gradle is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.netvariant.panic"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 21
versionCode 2
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile('com.twitter.sdk.android:twitter:1.13.1#aar') {
transitive = true;
}
compile 'com.skyfishjy.ripplebackground:library:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.android.support:multidex:1.0.1'
}
You seem to be missing jCenter()
repositories {
jCenter()
maven { url 'https://maven.fabric.io/public' }
}
Don't working this library from GitHub in Android Studio
My build.gradle(:project):
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.mymaterialdialogs"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile('com.afollestad.material-dialogs:core:0.8.4.2#aar') {
transitive = true
}
}
And My build.gradle(:app):
buildscript {
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Show this Error:
Error:(26, 13) Failed to resolve:
com.afollestad.material-dialogs:core:0.8.4.2 Show in
File(openFile:.../app/build.gradle)Show in Project Structure
dialog(open.dependency.in.project.structure)
Do the following steps:
1.In your build.gradle(:project) Add the following before dependencies
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile('com.afollestad.material-dialogs:core:0.8.4.2#aar') {
transitive = true
}
}
2.In your build.gradle(:app): replace
maven { url "https://jitpack.io" } with jcenter()
3.Sync project
Hope this helps.