I'm working on building an android library and I want to include a dependency of the library as a transitive dependency into my app. Here's my library's build.gradle file:
plugins {
id 'com.android.library'
id 'com.github.dcendents.android-maven'
}
group='com.github.rohg007.xxx'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//SDK level dependencies
implementation 'org.protoojs.droid:protoo-client:4.0.3'
api 'org.webrtc:google-webrtc:1.0.32006'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
implementation 'com.jakewharton.timber:timber:4.7.1'
}
repositories {
mavenCentral()
}
It works fine and all transitive dependencies are resolved when I include the library as a module:
implementation project(path: ':huddle01-android-sdk')
But when I release on Jitpack and include it as a dependency:
implementation 'com.rohg007.xxx:0.1.0'
or
implementation ('com.rohg007.xxx:0.1.0'){transitive=true}
It fails to resolve the webrtc dependency.
How to include the transitive dependency on release as well?
Jitpack uses ./gradlew install for generating the artifacts.
Adding an install block and manually appending the dependencies to the pom file worked for me.
Here's the install block that I added to the module level build.gradle file:
android {
...
}
dependencies {
...
}
install{
repositories{
mavenInstaller{
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each { dependency ->
if (dependency.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependency.group)
dependencyNode.appendNode('artifactId', dependency.name)
dependencyNode.appendNode('version', dependency.version)
}
}
}
}
}
}
I'm not sure if it's a clean solution to the problem. If there are cleaner alternatives, do let me know.
Related
I want to include a library in Android Studio , but it displays error like below :
Failed to resolve: com.andrognito.pinlockview:pinlockview:2.1.0
Failed to resolve: com.andrognito.patternlockview:patternlockview:1.0.0
How to fix this problem?
-build.gradle (App)
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.multiverse.appprotector"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
}
Other dependencies, which I consider are not relevant to the error:
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'junit:junit:4.13.2'
implementation 'androidx.test.ext:junit:1.1.3'
implementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.biometric:biometric:1.1.0'
Please go through link
If possible try latest library for the same because both libraries are not maintained from last few years.
Add jCenter repository in project’s build.gradle file as shown below and sync your project:
allprojects {
repositories {
jcenter()
. . .
}
}
Note- In the latest android code it will available in settings.gradle file
pluginManagement {
repositories {
jcenter()
...
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
jcenter()
..
}
}
The error is:
Could not resolve net.java.dev.jna:jna-platform
In the integration of Firebase to mu Grandle I get an error. I don't know if it's because the structure of the document was modified, since in mine it didn't contain "buildscript","allprojects".
I'm programming with java, not with kotlin in case it can help.
My gradle.app is
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.whatdowant"
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
///Implement para FIREBASE
implementation 'com.google.firebase:firebase-auth:21.0.3'
implementation 'com.google.android.gms:play-services:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:29.3.1')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
apply plugin: 'com.google.gms.google-services'
> `My gradle. project is:`
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// Add the following line:
classpath 'com.google.gms:google-services:4.3.10' // Google Services plugin
classpath "com.android.tools.build:gradle:4.2.2"
}
}
allprojects {
repositories {
mavenCentral()
google() // Google's Maven repository
}
}
```
I'd like to add the barteksc pdf dependencie but when I build my project it throw me this issue :
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
The dependencie:
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
I haven't been able to find any solution exept the offline toggle but in my case it doesn't change anything..
How can I make this work?
Edit:
Here's is my build.gradle settings:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "samere"
include ':app'
And here my gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "fr.frd.samere"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
}
Try adding jcenter()
https://github.com/barteksc/AndroidPdfViewer#installation
Library is available in jcenter repository, probably it'll be in Maven Central soon.
I am working on one android project created by someone. After I open this project in my Android studio, it gives an error:
ERROR: Unable to resolve dependency for ':app#debug/compileClasspath':
Could not resolve io.anyline:anylinesdk:5.
ERROR: Unable to resolve dependency for
':app#debugAndroidTest/compileClasspath': Could not resolve
io.anyline:anylinesdk:5.
//Build.gradle of my project
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion project.ext.compile_sdk_version
defaultConfig {
applicationId "com.xyz"
minSdkVersion 23
targetSdkVersion 26
versionCode 5
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters 'armeabi-v7a'
}
multiDexEnabled true
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/TrainedModels'] } }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url 'https://anylinesdk.blob.core.windows.net/maven/'
}
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:preference-v14:$support_version"
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'io.anyline:anylinesdk:5#aar'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.googlecode.libphonenumber:libphonenumber:7.2.2'
//
implementation ('com.google.android.gms:play-services-base:11.6.0'){
force=true
}
implementation ('com.google.android.gms:play-services-auth-api-phone:11.6.0'){
force=true
}
//Optional for phone number hint
implementation ('com.google.android.gms:play-services-auth:11.6.0'){
force=true
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
Could Anybody help me.
Here the issue is anyline sdk integration
Add Anyline SDK to the dependencies in build.gradle
repositories {
//add the anyline maven repo
maven { url 'https://anylinesdk.blob.core.windows.net/maven/'}
}
dependencies {
//add the anyline sdk as dependency (maybe adapt version name)
compile 'io.anyline:anylinesdk:3.6.1#aar'
//... your other dependencies
}
Or via local copy of the aar
Copy the .aar to the libs directory of your project (app/libs) and adapt build.gradle.
Add Anyline SDK to the dependencies in build.gradle
//root section of the file
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'anylinesdk-3.6.1', ext:'aar')
//... your other dependencies
}
Hope this will resolve.....
clean the project first(build->clean project)
then migrate to android x(Refactor -> migrate to androidx)
allow to changes recommended by the android studio
Error has resolved.Now Android studio is able to download anyline sdk.this error has been occured because url 'https://anylinesdk.blob.core.windows.net/maven/' had been blocked ITSEC of my company.
Thanks for your help
All my dependencies start from a verson 27, but the build task is still finishing with an Exception:
Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.4.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:25.4.0 [GradleCompatible]
I know that I can add
lintOptions {
abortOnError false
}
and it will fix my issue, but I want to establish the reason.
Here is my build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "my.company.app"
minSdkVersion 19
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "0.10.8"
vectorDrawables.useSupportLibrary = true
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://\"")
buildConfigField("String", "ENVIRONMENT", "\"release\"")
}
staging {
initWith debug
buildConfigField("String", "ENV_URL_PREFIX", "\"https://staging.\"")
buildConfigField("String", "ENVIRONMENT", "\"staging\"")
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://dev.\"")
buildConfigField("String", "ENVIRONMENT", "\"dev\"")
}
}
flavorDimensions "app"
productFlavors {
_Live {
dimension "app"
buildConfigField("String", "TYPE", "\"live\"")
}
_Test {
dimension "app"
buildConfigField("String", "TYPE", "\"test\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
exclude 'lib/x86_64/freebsd/libscrypt.so'
exclude 'lib/x86_64/linux/libscrypt.so'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.zxing:zxing-parent:3.3.3'
implementation 'com.google.zxing:core:3.3.2'
implementation 'com.google.guava:guava:22.0'
implementation project(':mobile_api') // a module compiled with java plugin
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
}
My idea that some of the dependencies transit a com.android.support libraries with version 25.4.0.
I would be grateful for any suggestions.
Thanks in advance!
You are using this library 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0',
and it in turn uses dependency 'com.android.support:cardview-v7:25.4.0'
Perhaps this is the cause of the conflict.
Add this to the very end of your root level build.gradle:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') { details.useVersion '27.x.x' }
}
}
To fix it I added a dependency
implementation 'com.android.support:cardview-v7:27.1.1'
in my build.gradle which overrides 25.4.0. Therefore, you do not need to look for a dependency that includes a breaking library.