Android studio does not Generate Signed APK - android

The Problem is that , I'm getting error while generating Signed APK using Allatori Java Obfuscator. I tried different hacks like, Invalidate and Clear cache /Restart,by deleting build folder, rebuilding project, Strings , Even tried comparing package names ,Class Naming conventions,possible jars, deprecated methods or classes but Its of no use.!
Multi Dex is enabled as well.! and I tried every possible Solution but unable to generate signed APK.
apply plugin: 'com.android.application'
apply plugin: 'ensighten'
ext {
supportVersion = "25.3.1"
googleServices = "11.4.2"
}
android {
def version = "2.0.0"
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "removed"
minSdkVersion 15
targetSdkVersion 25
versionCode 20
versionName "${version}"
multiDexEnabled true
def today = new Date().format('yyyyMMdd_HHmmss').toString()
project.ext.set("archivesBaseName", "MyApplication_Android_Build_"+ today + "_Version " + version);
}
applicationVariants.all { variant ->
variant.javaCompile.doLast {
runAllatori(variant)
}
}
buildTypes {
debug {
buildConfigField "boolean", "LOG_ENABLED", "true"
buildConfigField "boolean", "SSL_ENABLED", "true"
buildConfigField "String", "SERVER_URL", "\"http:///\""
}
release {
buildConfigField "String", "SERVER_URL", "\"http://\""
buildConfigField "boolean", "LOG_ENABLED", "false"
buildConfigField "boolean", "SSL_ENABLED", "true"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
android {
aaptOptions {
cruncherEnabled = false
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://ensighten-mobile.bintray.com/maven" }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.1'
classpath "com.ensighten.plugin.android:ensighten:2.0.1"
}
}
apply plugin: 'io.fabric'
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/vividadmin/maven" }
maven { url "https://ensighten-mobile.bintray.com/maven" }
mavenCentral()
google()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':williamchart')
compile "com.android.support:appcompat-v7:${project.ext.supportVersion}"
compile "com.android.support:design:${project.ext.supportVersion}"
compile "com.android.support:percent:${project.ext.supportVersion}"
compile "com.android.support:cardview-v7:${project.ext.supportVersion}"
compile "com.android.support:recyclerview-v7:${project.ext.supportVersion}"
compile "com.android.support:animated-vector-drawable:${project.ext.supportVersion}"
compile "com.android.support:gridlayout-v7:${project.ext.supportVersion}"
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile "com.google.firebase:firebase-crash:${project.ext.googleServices}"
compile "com.google.firebase:firebase-core:${project.ext.googleServices}"
compile "com.google.firebase:firebase-invites:${project.ext.googleServices}"
compile "com.google.firebase:firebase-messaging:${project.ext.googleServices}"
compile "com.google.android.gms:play-services-analytics:${project.ext.googleServices}"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'net.danlew:android.joda:2.9.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.scottyab:aescrypt:0.0.1'
compile 'net.cachapa.expandablelayout:expandablelayout:2.9.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.ensighten.android:ensighten-core:2.4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
def runAllatori(variant) {
copy {
from "$projectDir/allatori.xml"
into "$buildDir/intermediates/classes/"
expand(classesRoot: variant.javaCompile.destinationDir,
androidJar: "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar",
classpathJars: variant.javaCompile.classpath.getAsPath(),
logFile: "allatori-log-${variant.name}.xml")
rename('allatori.xml', "allatori-${variant.name}.xml")
}
new File("${variant.javaCompile.destinationDir}-obfuscated").deleteDir()
javaexec {
main = 'com.allatori.Obfuscate'
classpath = files("$rootDir/allatori/allatori.jar")
args "$buildDir/intermediates/classes/allatori-${variant.name}.xml"
}
new File("${variant.javaCompile.destinationDir}").deleteDir()
new File("${variant.javaCompile.destinationDir}-obfuscated").renameTo(new File("${variant.javaCompile.destinationDir}"))
}
Error:
Error:Error converting bytecode to dex:
Cause: PARSE ERROR:
class name (com/pckg/pakistan/myapplication/R) does not match path (com/pckg/pakistan/myapplication/r.class)
...while parsing com/pckg/pakistan/myapplication/r.class
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

As per my knowledge you are using lot of libraries and using Allatori Java Obfuscator due to Allatori obfuscation your java code is not being properly converted into byte code and thats the reason you are unable to generate signed apk. Try a quick hack delete build files ,gradle files and invalidate and restart your project more than once
Hope this may help u :)

There is no Signing config in Gradle you have added, So first Create a Keystore (https://developer.android.com/studio/publish/app-signing.html)
and then add in the app level Gradle
signingConfigs {
release {
// For making app store release config below parameters
storeFile file('path to keystore')
storePassword "keystore password"
keyAlias "Alias_of_keystore"
keyPassword "Keystore Password"
}
}
after that in build types add
buildTypes {
// For app store release uncomment below and select release build flavor in Build Variants
release {
...
signingConfig signingConfigs.release
}}

Related

When I add CMake path in gradle, build process stuck with StackOverflowError

I'm trying to implement this approach - https://www.androidsecurity.info/2016/12/15/storing-your-secure-information-in-the-ndk/.
The moment when I add cmake path in a gradle file,
externalNativeBuild {
cmake {
path 'src/CMakeLists.txt'
}
}
building process stuck with StackOverflowError.
_
Note. If I implement that approach in a new project, everything works fine - gradle builds successfully, and native method works in java class. The problem occurs when I do the same on my "production" project with many dependencies.
As you can see gradle stuck on "resolve artifact uiautomator-v18.aar". When remove "uiautomator" from dependencies, same error appears but with "espresso-core", remove "espresso-core" - "hamcrest-library" is the next, and so on.
All module build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
repositories {
jcenter()
}
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'io.fabric.tools:gradle:1.21.4'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
android {
lintOptions {
// google services plugin is causing missing translation issue
abortOnError false
disable 'MissingTranslation'
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.toolsVersion
signingConfigs { ... }
defaultConfig {
applicationId "..."
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
buildConfigField "boolean", "USE_ANALYTIC", "false"
buildConfigField 'boolean', 'USE_TRANSLATION', 'false'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "USE_ANALYTIC", "true"
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
debuggable true
buildConfigField "boolean", "USE_ANALYTIC", "false"
}
}
productFlavors {...}
externalNativeBuild {
cmake {
path 'src/CMakeLists.txt'
}
}
dataBinding { enabled = true }
}
configurations { ... }
dependencies {
...
// debug tools
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile rootProject.deps.firebaseMessaging
compile rootProject.deps.firebaseCore
compile rootProject.deps.firebaseConfig
compile 'com.squareup.picasso:picasso:2.5.2'
compile('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
exclude module: 'support-v4';
}
compile "com.android.support:support-vector-drawable:$supportLibrary"
compile "com.android.support:animated-vector-drawable:$supportLibrary"
compile rootProject.deps.appCompat
compile rootProject.deps.cardView
compile rootProject.deps.design
compile project(':sublimepickerlibrary')
compile project(':segmentedcontrol')
compile project(':stickyheaderlist')
compile "com.android.support:customtabs:$supportLibrary"
apt rootProject.deps.daggerCompiler
testCompile rootProject.testDeps.junit
testCompile rootProject.testDeps.intellijannotations
testCompile rootProject.testDeps.mockito
testCompile rootProject.testDeps.mockitoKotlin
androidTestCompile "com.android.support:support-annotations:$supportLibrary"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.artemzin.rxjava:proguard-rules:1.0.14.2'
compile rootProject.deps.rxAndroid
compile rootProject.deps.rxJava
}
configurations.all {
resolutionStrategy {
force "org.mockito:mockito-core:$mockito",
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.google.gms.google-services'
Appreciate any help - either direct answer or at least point out where to research.

Project refresh failed - Error:Cause: org/gradle/internal/TrueTimeProvider

Importing this project from github, I've run into this message:
Gradle 'GameOfLife-master' project refresh failed
Error:Cause: org/gradle/internal/TrueTimeProvider
I've tried solutions posted here, cleaned/rebuilt (at least attempted to) the project, invalidated caches and tried a different version of Gradle. None of that worked. Anyone else got any ideas?
Module: app - build.gradle
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "com.neenbedankt.gradle.plugins:android-apt:1.8"
classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'
classpath "net.rdrei.android.buildtimetracker:gradle-plugin:0.5.+"
classpath 'io.fabric.tools:gradle:1.+'
classpath 'hu.supercluster:paperwork-plugin:1.2.7'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'
apply plugin: 'hugo'
apply plugin: "build-time-tracker"
apply plugin: 'hu.supercluster.paperwork'
paperwork {
set = [
gitInfo: gitInfo(),
gitSha: gitSha(),
buildTime: buildTime("yyyy-MM-dd HH:mm:ss", "GMT+01:00")
]
}
def versionMajor = 1
def versionMinor = 2
def versionPatch = 0
android {
compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
defaultConfig {
applicationId 'hu.supercluster.gameoflife'
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
signingConfigs {
alpha {}
beta {}
release {}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
resValue "string", "app_name_for_buildtype", "Game of Life (debug)"
minifyEnabled false
testCoverageEnabled = false
}
alpha {
applicationIdSuffix ".alpha"
versionNameSuffix "-alpha"
resValue "string", "app_name_for_buildtype", "Game of Life (alpha)"
minifyEnabled false
testCoverageEnabled = false
lintOptions {
disable 'MissingTranslation'
}
}
beta {
applicationIdSuffix ".beta"
versionNameSuffix "-beta"
resValue "string", "app_name_for_buildtype", "Game of Life (beta)"
minifyEnabled false
testCoverageEnabled = false
}
release {
resValue "string", "app_name_for_buildtype", "Game of Life"
minifyEnabled false
proguardFile 'proguard-project.txt'
}
}
sourceSets.main {
// src/gen is the target for generated content like json model
java.srcDirs += 'build/generated/source/db'
}
// avoid errors with message 'Duplicate files copied in APK ...'
packagingOptions {
exclude 'LICENSE.txt'
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/ASL2.0'
}
}
afterEvaluate {
def propsFile = rootProject.file('keystore.properties')
def configName = 'release'
if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) {
def props = new Properties()
props.load(new FileInputStream(propsFile))
android.signingConfigs[configName].storeFile = rootProject.file(props['storeFile'])
android.signingConfigs[configName].storePassword = props['storePassword']
android.signingConfigs[configName].keyAlias = props['keyAlias']
android.signingConfigs[configName].keyPassword = props['keyPassword']
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.android.support:support-v13:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
// ---------
compile 'com.github.tslamic.adn:library:1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') { transitive = true }
compile 'com.jakewharton.timber:timber:2.5.1'
compile 'com.squareup:otto:1.3.6'
compile 'hu.supercluster:paperwork:1.2.7'
// ---------
apt "org.androidannotations:androidannotations:" + androidAnnotationsVersion
compile("org.androidannotations:androidannotations-api:" + androidAnnotationsAPIVersion )
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile('com.squareup:fest-android:1.0.+') { exclude module: 'support-v4' }
testCompile "org.robolectric:robolectric:3.0"
androidTestCompile 'com.google.guava:guava:14.0.1',
'com.squareup.dagger:dagger:1.1.0',
'org.hamcrest:hamcrest-integration:1.1',
'org.hamcrest:hamcrest-core:1.1',
'org.hamcrest:hamcrest-library:1.1',
'com.jakewharton.espresso:espresso:1.1-r3'
}
apt {
arguments {
resourcePackageName android.defaultConfig.applicationId
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
}
}
apply plugin: 'idea'
idea {
module {
//and some extra test source dirs
testSourceDirs += file('src/test')
}
}
apply from: 'build-time-tracker.gradle'
You could run with --stacktrace to get a full exception stack trace
Gradle has the concept of public API and private API. Basically anything in org.gradle.internal is a part of the private API and the gradle team can change / remove these classes between gradle versions. Ideally plugins should never reference internal classes. Any plugin author referencing internal API's must understand that this code may break with a new release of Gradle.
It looks like one of your plugins is referencing the internal API (org.gradle.internal.TrueTimeProvider) and the plugin was built against one version of Gradle and you are running with a different version of gradle.
To fix, you'll need to determine which plugin is throwing the exception (--stacktrace will help here). Then you'll either need to change the plugin version to one compatible with your version of gradle, or change the gradle version you are running with.

2 app icons after installing the release apk,using gradle build

I am using ./gradlew assembleRelease command to generate release apk for the app.On installing the app I am getting 2 icons of app.No clue what am I missing.No luch on google.
On clicking the second icon it just shows Simple Indeterminate.
Here is my build.gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
versionCode 23
versionName "1.1.8.5"
applicationId "com.squad.run"
minSdkVersion 10
targetSdkVersion 20
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
signingConfigs {
//Set debug.keystore file here
release {
def propsFile = rootProject.file('keystore.properties')
def Properties props = new Properties()
props.load(new FileInputStream(propsFile))
storeFile = file(props['storeFile'])
storePassword = props['storePassword']
keyAlias = props['keyAlias']
keyPassword = props['keyPassword']
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
ext.enableCrashlytics = false
}
release {
zipAlign true
signingConfig signingConfigs.release
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
// compile 'com.android.support:support-v4:20.0.0'
compile project(':Libraries:viewPagerIndicator_Squadrun')
compile project(':Libraries:facebookSDK')
compile project(':Libraries:library')
compile project(':Libraries:progressHUD_Squadrun')
compile project(':Libraries:slidingMenuLibrary_SquadRun')
compile project(':Libraries:MobihelpSDK')
compile 'com.squareup.retrofit:retrofit:1.5.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:appcompat-v7:21'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.squareup.okhttp:okhttp:1.6.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile 'org.twitter4j:twitter4j-core:4.0.1'
compile files('libs/FlurryAnalytics-4.1.0.jar')
compile 'com.crashlytics.android:crashlytics:1.0.0'
}
My top guess is that there is more than one LAUNCHER activity, and that one of them is declared in a library project. Eclipse didn't merge the manifests, but Gradle does.
So, I would suggest you search for android.intent.action.MAIN in all AndroidManifest.xml files.

Error with Android Gradle plugin 0.13 and android-apt 1.3

I've just updated my android gradle plugin from 0.12 to 0.13. Moreover I've downloaded gradle 2.1. Then, I tried with android studio 0.8.9 in beta but according http://tools.android.com/tech-docs/new-build-system/version-compatibility I have to use at least android studio 0.8.11 (canary channel). So I've updated my android studio but I have still the problem.
For now, I have to use gradle 1.10 and android gradle plugin 0.12.+ to work
Here the error from AS
Error:No such property: projectDependencies for class: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated
Edit :
Here is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// works with 0.12.+ (not with 0.13.+)
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// The latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
}
}
allprojects {
repositories {
maven { // For Android-ViewPagerIndicator
url "http://dl.bintray.com/populov/maven"
}
jcenter()
mavenCentral()
maven {
url "http://JRAF.org/static/maven/2"
}
}
}
Here is my gradle-wrapper.properties
#Fri Sep 19 17:50:42 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# use gradle-2.1-all.zip with android gradle plugin 0.13
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
EDIT 2 :
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId 'xxx'
minSdkVersion 10
targetSdkVersion 19
versionCode xxx
versionName 'xxx'
}
// For more information see
// #link http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Using-sourceCompatibility-1.7
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file('../../KeyStore/debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('xxx')
storePassword 'xxx'
keyAlias 'xxx'
keyPassword 'xxx'
}
}
buildTypes {
// Just intern. This is alpha build
debug {
buildConfigField "boolean", "FORCE_GOOG_GEO_API", "false" // can be set to true in debug but not in other buildTypes
buildConfigField "boolean", "ENABLE_LOG", "true"
buildConfigField "String", "HOST", "\"xxx\""
versionNameSuffix '-alpha'
signingConfig signingConfigs.debug
zipAlign true
}
// For customer
recette {
buildConfigField "boolean", "FORCE_GOOG_GEO_API", "false"
buildConfigField "boolean", "ENABLE_LOG", "false"
buildConfigField "String", "HOST", "\"xxx\""
versionNameSuffix '-recette'
signingConfig signingConfigs.debug
zipAlign true
}
// PreProd
preprod {
buildConfigField "boolean", "FORCE_GOOG_GEO_API", "false"
buildConfigField "boolean", "ENABLE_LOG", "false"
buildConfigField "String", "HOST", "\"xxx\""
signingConfig signingConfigs.debug
zipAlign true
}
// Prod
release {
buildConfigField "boolean", "FORCE_GOOG_GEO_API", "false"
buildConfigField "boolean", "ENABLE_LOG", "false"
buildConfigField "String", "HOST", "\"xxx\""
signingConfig signingConfigs.release
zipAlign true
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'AndroidManifest.xml'
}
}
apt {
arguments {
resourcePackageName android.defaultConfig.packageName
androidManifestFile variant.processResources.manifestFile
}
}
def GoogPlayServVersion = '5.0.+';
def GsonVersion = '2.2.4';
def LibPhoneNumbVersion = '5.9';
def GreenRobotVersion = '2.2.1';
def OkHttpVersion = '2.0.0';
def OkHttpConnVersion = '2.0.0';
def JacksonCore = '2.4.1';
def JacksonDatabind = '2.4.1';
def JacksonAnnotations = '2.4.0';
def SwitchVersion = '1.3.1';
def CroutonVersion = '1.8.4';
def ActionBarSherlockVersion = '4.4.0';
def ViewpagerIndicatorVersion = '2.4.1';
def PicassoVersion = '2.3.4';
def RoboSpiceVersion = '1.4.12';
def StickyListHeaders = '2.4.1';
def AAVersion = '3.1';
def RobotiumVersion = '5.2.1';
dependencies {
// Include all jar in libs folder
compile fileTree(dir: 'libs', include: ['*.jar'])
// Google Play Services
compile "com.google.android.gms:play-services:$GoogPlayServVersion"
// Gson
compile "com.google.code.gson:gson:$GsonVersion"
// LibphoneNumber
compile "com.googlecode.libphonenumber:libphonenumber:$LibPhoneNumbVersion"
// GreenRobot
compile "de.greenrobot:eventbus:$GreenRobotVersion"
// OkHttp [We use repackaged version #see https://github.com/square/okhttp/issues/967]
// compile "com.squareup.okhttp:okhttp:$OkHttpVersion"
// compile "com.squareup.okhttp:okhttp-urlconnection:$OkHttpConnVersion"
// Jackson
compile "com.fasterxml.jackson.core:jackson-core:$JacksonCore"
compile "com.fasterxml.jackson.core:jackson-databind:$JacksonDatabind"
compile "com.fasterxml.jackson.core:jackson-annotations:$JacksonAnnotations"
// Switch backport
compile "org.jraf:android-switch-backport:$SwitchVersion"
// Crouton lib
compile("de.keyboardsurfer.android.widget:crouton:$CroutonVersion") {
// exclusion is not neccessary, but generally a good idea.
exclude group: 'com.google.android', module: 'support-v4'
}
// You must install or update the Support Repository through the SDK manager to use this dependency.
// The Support Repository (separate from the corresponding library) can be found in the Extras category.
// compile 'com.android.support:support-v4:19.1.0'
// compile 'com.android.support:gridlayout-v7:19.1.0'
// ActionBarSherlock
compile "com.actionbarsherlock:actionbarsherlock:$ActionBarSherlockVersion#aar"
// Android-ViewPagerIndicator
compile "com.viewpagerindicator:library:$ViewpagerIndicatorVersion#aar"
// Picasso
compile "com.squareup.picasso:picasso:$PicassoVersion"
// Robospice
compile "com.octo.android.robospice:robospice:$RoboSpiceVersion"
// StickyList headers
compile "se.emilsjolander:stickylistheaders:$StickyListHeaders"
// Facebook sdk
compile 'fr.avianey:facebook-android-api:+#aar'
// android annotations
compile "org.androidannotations:androidannotations-api:$AAVersion"
apt "org.androidannotations:androidannotations:$AAVersion"
compile 'com.sothree.slidinguppanel:library:+'
// Tests part
androidTestCompile "com.jayway.android.robotium:robotium-solo:$RobotiumVersion"
compile "com.jayway.android.robotium:robotium-solo:$RobotiumVersion"
}
Do you know how can I solve this ?
Thx
android-apt 1.3 doesn't seem to be compatible with v0.13 of the Android Gradle plugin. Please use android-apt 1.4 instead:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Example gradle build files for referencing Crashlytics from App and Library projects

In reference to this post, does anyone have a pair of build.gradle files that demonstrate the basic setup for referencing Crashlytics from a android library project?
I get the following error even though I followed the recommendation provided via the post originally mentioned above.
This is my App gradle.build file.
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile project(':Common.Logger')
compile project(':Common.ProtocolBuffer')
compile project(':Common.Utils')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:+'
compile 'com.crashlytics.android:crashlytics:1.+'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
androidTestCompile 'junit:junit:4.11'
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
buildTypes {
debug {
buildConfigField "boolean", "USE_LOGCAT", "true"
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics=false
}
release {
runProguard true
debuggable false
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
buildConfigField "boolean", "USE_LOGCAT", "false"
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics=true
}
}
sourceSets {
packagingOptions {
exclude 'LICENSE.txt'
}
lintOptions {
abortOnError false
}
}
}
This is my current Library build.gradle file.
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.crashlytics.android:crashlytics:1.+'
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
buildTypes {
debug {
buildConfigField "boolean", "USE_LOGCAT", "true"
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics=false
}
release {
buildConfigField "boolean", "USE_LOGCAT", "false"
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics=true
}
}
sourceSets {
lintOptions {
abortOnError false
}
}
}
I was told by Crashlytics support some time ago to simply use the 'ext.enableCrashlytics' flag in a buildType.
The following is the current gradle error that occurs using the above gradle build files.
Error:A problem occurred configuring root project 'ManageMyVMail.Android'.
> A problem occurred configuring project ':Common.ProtocolBuffer'.
> Could not resolve all dependencies for configuration ':Common.ProtocolBuffer:_debugCompile'.
> Could not find any version that matches com.crashlytics.android:crashlytics:1.+.
Required by:
ManageMyVMail.Android:Common.ProtocolBuffer:unspecified > ManageMyVMail.Android:Common.Logger:unspecified
As a secondary question, do I need to create the same set of buildConfigField values in both files if I want to use them from both projects after I get past the current gradle build error. I am fairly new to Gradle and Android Studio, but searching the Intertron just has not produced an answer yet.
Thank you in advance.
After a few emails with Crashlytics support, I found a solution. There were two aspects to the final solution.
The error message originally posted was stating the situation, I was just not reading it correctly. Simply, the library project that did not need Crashlytics depended on the other library project that did need Crashlytics. Adding the Crashlytics dependency to the aforementioned library solved the Gradle build issue.
The Crashlytics API key had to be added to the library project manifest depending on Crashlytics. The project built, but did not submit my "log" messages at runtime, so this was an obvious fix once I made the connection.
I have included the Gradle files from each of the (3) projects involved in my scenario. Hope this helps others and thanks to Mike at Crashlytics for responding to my messages.
App.gradle (calls Crashlytics.start())
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile project(':Common.Logger')
compile project(':Common.ProtocolBuffer')
compile project(':Common.Utils')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:+'
compile 'com.crashlytics.android:crashlytics:1.+'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
androidTestCompile 'junit:junit:4.11'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
buildTypes {
debug {
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
}
release {
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
runProguard true
debuggable false
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
sourceSets {
packagingOptions {
exclude 'LICENSE.txt'
}
lintOptions {
abortOnError false
}
}
}
Common.Logger.gradle (calls Crashlyics.log())
apply plugin: 'android-library'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.crashlytics.android:crashlytics:1.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
buildTypes {
debug {
ext.enableCrashlytics = false
}
release {
ext.enableCrashlytics = true
}
}
sourceSets {
lintOptions {
abortOnError false
}
}
}
Common.ProtocolBuffer.gradle (depends on Common.Logger, no Crashlytics calls)
apply plugin: 'android-library'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.google.protobuf:protobuf-java:2.4.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.crashlytics.android:crashlytics:1.+'
compile project(':Common.Logger')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
lintOptions {
abortOnError false
}
}
}

Categories

Resources