External dependency not included after deploy to artifactory - android

I develop small mvp library with included some dependency like butterknife and glide, but after it is already deployed to my private artifactory, all the dependency is not included with my library, so all the dependency is not resolved in my project when using this library. I am new with this artifactory, is I am missing something?
This is my root build.gradle :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my build.gradle module :
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'me.tatarka.retrolambda'
def libraryGroupId = 'com.pixilapps.pixilframework'
def libraryArtifactId = 'mvp'
def libraryVersion = '1.0.0'
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
}
}
}
artifactory {
contextUrl = 'http://my.lib.web/artifactory'
publish {
repository {
repoKey = 'libs-release-local'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
}
}
repositories {
mavenCentral()
jcenter()
maven { url "https://clojars.org/repo/" }
maven { url "https://jitpack.io" }
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven {
url "http://dl.bintray.com/glomadrian/maven"
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 17
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8.toString()
targetCompatibility JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
final PLAY_SERVICES_VERSION = '9.6.1'
final DEXMAKER_VERSION = '1.4'
final HAMCREST_VERSION = '1.3'
final ESPRESSO_VERSION = '2.2.1'
final RUNNER_VERSION = '0.4'
final AUTO_VALUE_VERSION = '1.3'
final AUTO_VALUE_GSON_VERSION = '0.4.2'
final SUPPORT_LIBRARY_VERSION = '25.1.0'
final RETROFIT_VERSION = '2.1.0'
final BUTTERKNIFE_VERSION = '7.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.jakewharton.timber:timber:4.1.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.vistrav:ask:2.4'
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'net.danlew:android.joda:2.9.3.1'
compile 'com.pixplicity.easyprefs:library:1.7'
}

You can use pom.withXml in your publishing block, as described here (find the official documentation about pom.withXml here).
It will look like something approaching this, I guess:
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version = libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName("_releaseCompile").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}

Related

Could not resolve all files for configuration ':app:debugRuntimeClasspath gradle submodule dependency

I have a submodule project that turns into Maven repository, I'm trying to use a dependency implementation com.github.jkwiecien:EasyImage:3.0.3 other like Glide works, but this issue appears:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.jkwiecien:EasyImage:3.0.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://jcenter.bintray.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://maven.google.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://repo.maven.apache.org/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
Required by:
project :app > project : myapp
I've tried putting maven repository as:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
def githubProperties = new Properties()
githubProperties.load(
new FileInputStream(rootProject.file("github.properties"))
)
def getVersionName = { ->
return "1.0.9"
}
def getArtifactId = { ->
return "rewards"
}
publishing {
publications {
rewards(MavenPublication) {
groupId 'app.my.sdk'
artifactId getArtifactId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtifactId()}-release.aar")
pom.withXml { // adding transitive dependencies...
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
if (dep.group == null || dep.version == null ||
dep.name == null || dep.name == "unspecified")
return
final dependencyNode = dependenciesNode
.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', scope)
if (!dep.transitive) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
dep.properties.excludeRules.each { ExcludeRule rule ->
exclusionNode.appendNode(
'groupId', rule.group ?: '*')
exclusionNode.appendNode(
'artifactId', rule.module ?: '*')
}
}
} // end addDependency
configurations.compile.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.api.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.implementation.getDependencies().each { dep ->
addDependency(dep, "runtime")
}
} // end pomWithXml
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/my-project/my-lib")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
repositories {
maven {
URL "https://mvnrepository.com/artifact/com.github.jkwiecien/EasyImage"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'jp.wasabeef:blurry:4.0.0'
implementation 'io.socket:socket.io-client:1.0.0'
implementation 'com.github.jkwiecien:EasyImage:3.0.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}
This is my full gradle file. I'm working only with this module, It's suppose to be an app inside another. I'm uploading in github packages using the maven.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
To solve this issue just add jitpack on gradle project file,
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

I can't publish an android library using maven-publish plugin

I have an android project inside the project I have an android module. I try to publish an maven artifact but I got the next message Publications(s) specified but no publications exist in project :.
My project build.gradle is the next:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.8.5"
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My gradle module is the next:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 29
buildToolsVersion "30.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'io.github.rockbass2560'
artifactId = 'imageprogress'
version = '1.0.0'
}
}
}
}
def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
bintray {
user = localProperties.getProperty("bintray.user")
key = localProperties.getProperty("bintray.apikey")
publications = ['release']
pkg {
repo = 'imageprogress'
name = 'imageprogress'
userOrg = user
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/rockbass2560/ImageProgress.git'
version {
name = '1.0-Final'
desc = 'First version for ImageProgress plugin'
released = new Date()
vcsTag = '1.0.0'
attributes = ['version': '1','released':true]
}
}
}
I have made tutorials on android page and other pages but I can't get fix the issue.

Maven Repository on Github not downloading transitive dependencies

I have created a maven repository and uploaded it to Github. When I add it as a dependency to a sample project, the gradle sync completes successfully. But when I try to run the app, it crashes with a java.lang.NoClassDefFoundError.
Link to repository: https://github.com/rjain90/sdk
Sample project code:
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
kotlin_version = '1.3.20'
realm_version = '5.8.0'
}
repositories {
google()
jcenter()
maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:$realm_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
lifecycle_version = '2.0.0'
android_support_version = '1.1.0-alpha01'
legacy_support_version = '1.0.0'
constraint_version = '1.1.3'
retrofit_version = '2.4.0'
dagger_version = '2.16'
rxjava_version = '2.1.7'
rxandroid_version = '2.0.1'
}
Module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
// Load keystore
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
release {
keyAlias keystoreProperties['ANDROID_KEY_ALIAS']
keyPassword keystoreProperties['ANDROID_KEY_PASSWORD']
storeFile file(keystoreProperties['ANDROID_KEYSTORE_LOCATION'])
storePassword keystoreProperties['ANDROID_STORE_PASSWORD']
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.bowstring.godworld"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.release
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.appcompat:appcompat:$android_support_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation "androidx.legacy:legacy-support-v4:$legacy_support_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.cabfare.android:sdk:0.0.18#aar'
}
For GitHub hosted, you can use https://jitpack.io as a Maven repository.
Add maven { url 'https://jitpack.io' } into the project build.gradle's allprojects -> repositories block, then in your module build.gradle, add a dependency implementation 'com.github.rjain90:sdk:0.0.17', for example.
However, your two releases are both containing build errors. Solve them first.

Kotlin gradle multi level project issue

I want to use the common module both on mobile and backend. In backend module everything works fine, but I can't use common module on mobile. When I was build mobile project I got an error: Project with path ':common' could not be found in project ':app'
Project tree:
kibar
.git
gradle
idea
backend
src
build.gradle
common
src
build.gradle
mobile
.gradle
.idea
app
src
build.gradle
proguard-rules.pro
build.gradle
settings.gradle
settings.gradle
kibar:settings.gradle
rootProject.name = 'kibar'
include 'backend', 'mobile', 'common'
common:build.gradle
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
}
repositories {
mavenCentral()
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.71"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
backend:build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
jcenter()
mavenCentral()
maven { url "http://dl.bintray.com/kotlin/kotlin-eap" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = "App"
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/exposed" }
maven { url "http://dl.bintray.com/kotlin/kotlin-eap" }
}
dependencies {
compile project(":common")
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}
idea {
module {
sourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
generatedSourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
}
}
sourceSets {
main.resources.srcDir('conf')
main.java.srcDirs += 'src/main/java'
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
mobile:build.gradle
buildscript {
ext{
kotlin_version = "1.2.71"
lifecycle_version = "2.0.0"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
}
}
mobile:settings.gradle
include ':app'
mobile.app:build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
buildToolsVersion = '28.0.3'
compileSdkVersion 28
defaultConfig {
versionCode 1
versionName "1.0"
applicationId "com.example"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
androidExtensions {
experimental = true
}
kapt {
generateStubs = true
}
kotlin {
experimental {
coroutines "enable"
}
}
dependencies {
compile project(':common')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.30.2'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
}
You should have only one settings.gradle file in your whole project, at root directory level. Remove the mobile/settings.gradle.
Gradle multi-project build is expecting a single settings.gradlefile located in project root directory , and this settings.gradlemust declare all sub-projects. In your case, you need to add mobile:app sub-project in your kibar:settings.gradle file:
rootProject.name = 'kibar'
include 'backend', 'mobile:app', 'common'
For reference: https://docs.gradle.org/current/userguide/build_lifecycle.html#sec:settings_file

Failed to resolve: com.android.support:palette-v7:26.0.1

I am having this error on Android Studio:
Error:Failed to resolve: com.android.support:palette-v7:26.0.1
Install Repository and sync project
Open File
Show in Project Structure dialog
When I click 'Install Repository and sync project' nothing happens.
I already checked and tried similar questions's answers. But still problem exists.
Here is my project level build.gradle code:
// 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.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my app level build.gradle code:
apply plugin: 'com.android.application'
apply from: "$rootDir/utils.gradle"
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
//repositories {
// maven { url 'https://maven.fabric.io/public' }
//}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
maven { url 'https://maven.fabric.io/public' }
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
def applicationName = "xyz"
defaultConfig {
applicationId "xyz"
minSdkVersion 15
targetSdkVersion 26
versionCode 16
versionName "1.7"
manifestPlaceholders = [onesignal_app_id : "xyz",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField 'String', 'END_POINT', toJavaCodeString(END_POINT)
}
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
storeFile file('../keystore/debug.jks')
}
release {
keyAlias 'xyz'
keyPassword 'xyz'
storePassword 'xyz'
storeFile file('../../../Keystore/xyz.keystore')
}
}
productFlavors {
dev {
signingConfig signingConfigs.debug
versionCode defaultConfig.versionCode
versionName defaultConfig.versionName
applicationId "xyz"
}
prod {
signingConfig signingConfigs.release
versionCode defaultConfig.versionCode
versionName defaultConfig.versionName
applicationId "xyz"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
applicationVariants.all { variant ->
variant.outputs.each { output ->
def date = new Date();
def formattedDate = date.format('dd-MM - HH:mm:ss')
output.outputFile = new File(output.outputFile.parent,
output.outputFile.name.replace("app-prod-release", applicationName + " v" + defaultConfig.versionName + " - " + formattedDate)
)
}
}
}
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), "rules-proguard-debug.pro"
signingConfig signingConfigs.debug
}
}
lintOptions {
abortOnError false
}
}
ext {
supportLibraryVersion = "26.0.1"
}
repositories {
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://maven.google.com"
}
}
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:${supportLibraryVersion}"
compile "com.android.support:design:${supportLibraryVersion}"
compile "com.android.support:palette-v7:${supportLibraryVersion}"
compile "com.android.support:recyclerview-v7:${supportLibraryVersion}"
compile "com.android.support:cardview-v7:${supportLibraryVersion}"
compile "com.android.support:customtabs:${supportLibraryVersion}"
// compile "com.android.support:support-dynamic-animation:${supportLibraryVersion}"
compile 'com.tsengvn:typekit:1.0.1'
compile 'com.jakewharton.timber:timber:4.5.0'
compile 'com.mikepenz:iconics-core:2.8.2#aar'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0#aar'
compile 'com.mikepenz:community-material-typeface:1.7.22.1#aar'
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'pub.devrel:easypermissions:0.2.1'
compile('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.balysv:material-ripple:1.0.2'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile 'com.inthecheesefactory.thecheeselibrary:adjustable-imageview:1.0.0'
compile 'com.github.florent37:viewanimator:1.0.5'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
// compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.afollestad.material-dialogs:core:0.9.4.7'
compile 'com.afollestad.material-dialogs:commons:0.9.4.7'
// compile 'com.onesignal:OneSignal:3.+#aar'
// compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
def gmsVersion = '11.2.+'
compile("com.google.android.gms:play-services-gcm:${gmsVersion}") {
force = true
}
compile("com.google.android.gms:play-services-location:${gmsVersion}") {
force = true
}
compile("com.android.support:support-v4:${supportLibraryVersion}") {
force = true
}
compile("com.android.support:support-v13:${supportLibraryVersion}") {
force = true
}
compile("com.android.support:customtabs:${supportLibraryVersion}") {
force = true
}
compile 'com.google.android.gms:play-services-ads:' + gmsVersion
compile 'com.anjlab.android.iab.v3:library:1.0.+'
// compile 'org.solovyev.android:checkout:1.0.0'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
// testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
}
Project and app level build.gradle code added.
Any idea? Thanks!
This is the best way to do it.
In your root level gradle.build use below
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and in your gradle-wrapper.properties file change the wrapper version as below
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
also in your app level build.gradle make sure you are using 26 vesion as below
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Categories

Resources