crashlytics android studio gradle build failed - android

I have installed crashlytics plugin to android studio 0.9.3; after this I added to my project; It added lines to gradle, first activity and so on...; after this build fails with this error:
Error:Execution failed for task ':app:fabricCleanupResourcesDebug'.
Crashlytics Developer Tools error.
Here is my gradle file, what should I change ? Crashlytics added it's lines automatically:
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'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "XXXXXXXXXXXXXXXXXXXXXXX"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir : 'libs', include : ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
}
.

I just had the exact same issue after replacing the API Key in the AndroidManifest.xml file by a string reference instead of a literal string.
Using the literal string, the error disappeared.
Use
<meta-data
android:name="com.crashlytics.ApiKey"
android:value="mykey" />
Don't use
<meta-data
android:name="com.crashlytics.ApiKey"
android:value="#string/crashlytics_api_key" />

I have solved the issue.
I had long conversation with crashlytics team, but they didn't helped me.
My solution is to create separate project, and install crashlytics on that project. It will generate api key on that project. I just copied that key and pasted to my original project and it worked. Have no idea why it didn't generated the key on my initial project.

yes,I add this code in AndroidManifest.xml,it worked
<meta-data
android:name="io.fabric.ApiKey"
android:value="yourapikey" />

On first run of app without internet connection, app can not send information to server, so register your app in server.

This error due to wrong crashlaytics AppKey. Please check your manifest file for confirm it. OR
It is due to use of a string resource instead of Hardcoded AppKey in manifest file.
Use this:
<meta-data
android:name="io.fabric.ApiKey"
android:value="FABRIC_KEY"/>
Dont Use this
<meta-data
android:name="io.fabric.ApiKey"
android:value="#stringFABRIC_KEY"/>
All the best

Open fabric.properties and check if value against apiKey reads YOUR_API_KEY.
If yes then copy your API Key from AndroidManifest.xml and paste it against apiKey in the fabric.properties.

Related

Error:Gradle: Execution failed for task ':app:crashlyticsCleanupResourcesDebug'. > Crashlytics Developer Tools error

I have this mainActivity
public class MainActivity extends RoboFragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Crashlytics.start(this);
//setContentView(R.layout.activity_main);
Intent intent = new Intent(this, MainActivity_with_Fragment.class);
startActivity(intent);
finish();
}
}
this is my gradle.build
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.2'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.stopcall.app"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
provided 'org.roboguice:roboblender:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
When I run project build I get this compilation error:
Error:Gradle: Execution failed for task ':app:crashlyticsCleanupResourcesDebug'.
> Crashlytics Developer Tools error.
how can I fix this?
You need to add your API Key to the Android Manifest:
<application>
<meta-data
android:name="com.crashlytics.ApiKey"
android:value="your key here" />
</application>
This method solved my problem:
Remove or Comment this line (build.gradle):
// apply plugin: 'io.fabric'
or if you have an ApiKey, define fabric ApiKey (AndroidManifest.xml)
<meta-data
android:name="io.fabric.ApiKey"
android:value="yourApiKey012356465654" />
If you only want to compose a tweet with the SDK you can remove the line
apply plugin: 'io.fabric'
And the gradle build will work correctly
I also got the issue and resolved it by putting string directly in meta tag without defining the api key into string resources. e.g.
Replace
<meta-data
android:name="io.fabric.ApiKey"
android:value="#string/string_res_name_of_your_api_key" />
to
<meta-data
android:name="io.fabric.ApiKey"
android:value="your_api_key_string" />
When you follow the steps for adding an application in your Crashlytics dashboard, they have mentioned a step to add the api key. In my case I was getting the same error when I would try to fetch the key from the strings.xml file. The problem was that crashlytics plugin uses a runtime api key insertion method and hence the build fails as it is not able to get the key from the strings file.
I tried below step:
Add a manifest placeholder in your build.gradle's defaultConfig:
defaultConfig {
manifestPlaceholders = [ api_key_crashlytics:"xxxx__your_api_key"]}
In your AndroidManifest.xml add below code inside your application tag:
<meta-data
android:name="io.fabric.ApiKey"
android:value="${api_key_crashlytics}" />
This worked for me.
Please make sure you added
apply plugin: 'com.google.gms.google-services'
at the end of your build.gradle file.
Open the Fabric Plugin which is already installed and update the Crashlytics, your problem gets solved
I faced with this issue for sometimes, although I already had api key in manifest. Then I try assemble release apk before try to assemble to upload to Fabric. So let execute:
$ ./gradlew assembleRelease
then
$ ./gradlew assembleRelease crashlyticsUploadDistributionRelease
and it works well.
If you use distribution with Gradle you may have checked some properties like
ext.betaDistributionReleaseNotesFilePath=”path/to/release_notes.txt”
In our case we didn't have this file and the task crashed. To see the problem, go to Gradle console and check logs:
I tried all of your solution suggests under that question and others. But all of them did not solve my problem. I solved my problem. My solution may solve your problem. I created empty res folder under main folder. project->src->main->res
Most likely the ApiKey is not correct just check it out. Worked for me.
Your key may have been entered on the wrong Android Manifest
<meta-data
android:name="io.fabric.ApiKey"
android:value="yourApiKey" /> //You must have 40 words
You can get the code after registering and entering the project
https://fabric.io/home

Android Studio 0.9.0 - Cannot resolve symbols

After 6h spent trying to fix this by myself, AS is driving me crazy. Everything was fine yesterday and today it can't resolve any of the support libs nor the R symbols.
I tried everthing, including all the suggested fixes I found on StackOverflow. No need to tell me to have a look a this post, I already have and none of the solutions work.
Here's what I tried so far :
rebuilding / cleaning the project (many times...),
synchronising the project with Gradle Files,
check that the support lib is up-to-date in the SDK Manager,
invalide Caches / restart AS,
delete the .idea folder and the .iml files of my project, and re-importing it in AS,
update AS from 0.8.11 to 0.9,
eventually I ended up uninstalling AS and reinstalling it from scratch
And none of this fixed my issue...
Something really weird is that I also tried to create a whole new project from scratch and to copy/paste all my classes & resources from my corrupted project to this new one. And it worked for a while (~10 min), until it eventually became corrupted the same way, without any apparent reason.
Moreover, no idea if it's relevant, but when I type "ViewPager" in AndroidStudio and hit CTRL-SPACE, it doesn't suggest me the "android.support.v4.view.ViewPager" class. But if I hit CTRL-SPACE 3 times in a row, it DOES suggest it. So I guess that means that it's able to find the support lib somewhere but not to use it?
Here's my build.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mathieumaree.library"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v13:21.0.0'
}
Please, help me, otherwise I'm gonna break my computer soon.
Thanks in advance,
Mathieu
EDIT 1 :
I forgot to mention that this occurs only in one of my projects. The others seem to be fine (at least for now).
EDIT 2 :
I also forgot to mention that my project is composed of an application project plus a library module inside it. So here is the app's build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mathieumaree.materialheaderviewpager"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.android.support:support-v13:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
}
The app Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.materialheaderviewpager" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.mathieumaree.materialheaderviewpager.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The library manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.library">
<application android:allowBackup="true"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
</application>
</manifest>
The main settings.gradle :
include ':app', ':library'
And the main build.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:0.14.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
EDIT 3 :
After trying once more to delete all .idea folers & *.iml files and reloading my project, I noticed that AndroidStudio displayed an error at openning :
Accessing invalid virtual file:
file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21;
original:582; found:-: Accessing invalid virtual file:
file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21;
original:582; found:-
I'm pretty sure it means it's looking for the SDK to yet another location (AppData/Local...android-21). What I don't understand is :
there's no SDK folder at this location
the SDK path indicated in the Project Structure is not this one
Any idea what all this means?
try addind this to buid.gradle
compile 'com.android.support:support-v4:21.0.0
and change build tools version to 20.0.0
Also create a whole new project and see if the same errors are still present in that project.
Try "Tools" -> "Android" -> "Sync Project with Gradle Files"
Well, still not a clue what caused this problem but it would look like I managed to get rid of it, although I had to create a new project from scratch. What I really don't understand is that I've already done this yesterday and it didn't work out.

crashlytics developer tools error when building android -gradle project

I'm trying to build an android gradle project using eclipse, but i get this error when building the project using the command line:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:crashlyticsCleanupResourcesRelease'.
> Crashlytics Developer Tools error.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
I'm using gradle version 1.10 also tried gradle version 1.12 but i get the same error
and here is my build.gradle file :
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
}
}
apply plugin: 'android-sdk-manager'
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
lintOptions.checkReleaseBuilds false
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
signingConfigs {
release {
storeFile file(STORE_FILE)
storePassword STORE_PASSWORD
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
}
}
buildTypes {
debug {
ext.enableCrashlytics = false
buildConfigField "boolean", "LOG_CRASHES", "false"
}
release {
buildConfigField "boolean", "LOG_CRASHES", "true"
runProguard true
proguardFile 'proguard.cfg'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
Had a similar error trying to use Fabric's Twitter Kit
Error:Execution failed for task ':app:fabricCleanupResourcesDevDebug'.
> Crashlytics Developer Tools error.
Detailed error
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: XXXXXXXXX.
Check the Crashlytics plugin to make sure that the application has been added successfully!
Contact support#fabric.io for assistance.
After login in Fabric, download the AndroidStudio plugin and let it configure everything all worked fine.
(Btw, I really don't like this setup flow)
EDIT: It also can be done without install the AndroidStudio plugin. Follow these instructions from the Fabric site https://fabric.io/downloads/gradle
This is not a solution to the original question, but you can also run into this error another way. If you are following docs for the Gradle Advanced Setup you might have included the following code
debug {
ext.enableCrashlytics = false
}
Now if you are testing your application you may have tried to set ext.enableCrashlytics = true instead. Apparently this will cause errors for Crashlytics though and is not a valid value for this variable.
So if you want Crashlytics enabled for debug builds you'll need to comment out this line while you are testing or remove it altogether.
By adding this line to your Application's Manifest inside tag
<meta-data
android:name="io.fabric.ApiKey"
android:value="XXXXXXXXXXXXXXX" />
I resolved this issue
I fixed this issue by replacing "io.fabric.ApiKey" with "com.crashlytics.ApiKey" in AndroidManifest.xml (I don't like to change the Crashlytics lib). So the final one is:
<meta-data
android:name="com.crashlytics.ApiKey"
android:value="xxxxxxxx" />
<meta-data
android:name="com.crashlytics.ApiKey"
android:value="your key" />
I had simillar issue. Just add these line to your Android manifest file.
So I was having this issue and resolved it.
Basically, I was trying to use #string/crashlytics_key_prod, instead of putting in the actual key.
Replacing "#string/crashlytics_key_prod" by the actual key in the manifest resolved this issue for me.

Android Studio builds two applications for the same project simultaenously

I'm making an app using Android Studio v0.5.9, which has a library project as a dependency. But, every time I run the project two apks having the same name and icon, are deployed to my device. The first apk(app) contains my main module, whereas, the second one is the library project itself. However, when I run the same project from Eclipse, only one apk is deployed and it works perfectly.
Here are some screenshots of the problem -
First App(My module) -
Second App(library project) -
top-level build.gradle file -
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}
main module build.gradle file -
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
packageName 'com.Swap.Rooms'
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:appcompat-v7:19.+'
compile project(':lib')
}
library project build.gradle file -
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
packageName "com.jfeinstein.jazzyviewpager"
minSdkVersion 4
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/nineoldandroids-2.4.0.jar')
}
settings.gradle -
include ':app'
include ':lib'
Please help me to fix this. Thanks in advance!!
Maybe this will be helpful for others.
Gradle is doing manifest merge for library projects as well. So issue was to keep AndroidManifes.xml unchanged from library. It had application node for demo purposes and this node was successfully merged to main AndroidManifest.xml.
I'm going to submit issue to Google since I think it should prevent or warn about such situation.
Eugen Martynov answer is correct but i decided to reiterate what he said in layman's terms.
Go through your libraries and check their AndroidManifest.xml. One of them should have an <application> tag in it. Remove the tag and the double app problem will be solved.
The specific element in the ApplicationManifest.xml, that affects creating multiple launcher icons is the <intent-filter> containing <category android:name="android.intent.category.LAUNCHER"/>. Removing this <intent-filter> will give you control over the number of launcher icons. You can read a bit more elaborate SO answer here.
It took me time to realize where the issue was.But finaly worked out for me.
The issue is with the Manifest.xml file. It means that you have two activities set as LAUNCHER.
just remove the code simmilar to the one below from the activity that is not your LAUNCHER
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Android Studio and google play services error

I want to add admob to my project and have followed the instructions from the documentation but I'm getting an error:
Cannot find symbol '#integer/google_play_services_version
inside the AndroidManifest.xml. I've looked inside the sdk directory and google_play_services version 4.0.30 is installed. Here's my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/libGoogleAnalyticsServices.jar')
compile 'com.google.android.gms:play-services:4.0.30'
}
After adding it, I've synced the project with gradle. I also have the required entry in AndroidManifest.xml which gives me the error
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
The official docs say that for android studio we don't need to include the library but I don't understand why it doesn't find it.
Edit: I finally solved it. The problem was that I was using the wrong sdk. Android studio ships with its own SDK and that was set as default in the IDE.
To fix
Change your project's SDK from android-studio\\sdk to android-sdk. If you don't know how, here's how.
If you get an error about build tools not found make sure the version in your build.gradle corresponds to your new sdk's version.
You must have Google Repository installed in order to use Google Play Services in Android Studio.
If not Installed it from SDK Manager > Extras.
After Installation your library should be located on path
$SDK_DIR\extras\google\m2repository\com\google\android\gms\play-services

Categories

Resources