Build library Github with Jitpack include dependencies - android

I'm building a library with jitpack.io I was able to build and compile into the application successfully, but the problem here is that in the library there includes a number of other libraries compiled into
implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
implementation 'com.appnext.sdk:banners:2.4.2.472'
implementation 'com.appnext.sdk:ads:2.4.2.472'
implementation 'com.appnext.sdk:native-ads2:2.4.2.472'
implementation 'org.jsoup:jsoup:1.11.3'
so when I compiled the library into my application and called it, it reportedly did not find the class I was including into libraries(org.jsoup., com.appnext., ..). If I want to use I have to re-declare the libraries on again in my application. Is there a way to not do this, as includes the library inside

I was facing the same issue and apparently it's a bug in maven gradle plugin v1.5; problem solved after my plugin version is updated to 2.1.
Issue: https://github.com/dcendents/android-maven-gradle-plugin/issues/61
Related Answer: https://stackoverflow.com/a/51190164/1640033

Related

What exactly is runtimeOnly on androidx.appcompat:appcompat

I'm working with old version of appcompat, but error after migrate to androidX.
implementation 'com.android.support:appcompat-v7:28.0.0'
Should i use implementation instead of runtimeOnly ?
After androidx migration your dependency would have been changed to following:
implementation "androidx.appcompat:appcompat:1.5.1"
If above is already present in your build.gradle then you can safe remove appcompat-v7 dependency.
As far as using implementation or runtimeOnly it totally depends upon dependency usage. If its usage in compile time then use implementation or if this just require in runtime use runtimeOnly.
To get your answer please refer to the link: Dependency configurations
According to the description mentioned in above link:

How to ensure all firebase SDKs are the compatible version?

Currently we have a lot of firebase version.
firebase_core_version = '16.0.6'
firebase_perf_version = '16.2.2'
firebase_messaging_version = '17.3.4'
...
implementation "com.google.firebase:firebase-core:$firebase_core_version"
implementation "com.google.firebase:firebase-perf:$firebase_perf_version"
implementation "com.google.firebase:firebase-messaging:$firebase_messaging_version"
...
But they each have different version number and sometimes they are conflicting or resolved to unexpected versions by transitive includes. Or other module declares different version for same library... That steals my time.
Is there any solutions for this?
Gradle has "BoM" feature that is available from 5.0. and it enables you free from version hell.
implementation platform('com.google.firebase:firebase-bom:20.0.1')
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-appindexing'
implementation 'com.google.firebase:firebase-config'
You may notice that only new import firebase-bom has version and any other libraries don't have version.
This is because BoM dependency contains all firebase version inside it (of course they are compatible!).
So your module always import firebase-bom then version conflict will be gone.
firebase-bom is currently experimental but it works for me.
https://firebase.google.com/docs/android/setup#firebase-bom
I hope androidx (jetpack) also have this!
There is also okhttp-bom available.
https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-bom

Cannot resolve symbol 'MediaSessionCompat'

I cannot import MediaSessionCompat.
The import statement for importing the whole android.support.v4.media library does not show up in the Android Studio "IntelliSense" and it cannot resolve the symbol for anything inside it.
Do I have to make some kind of extra configuration to get this import, like in app build.gradle?
Add these to your dependencies and sync Gradle:
Pre-AndroidX
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
Post-AndroidX
implementation 'androidx.core:core:1.8.0'
implementation 'androidx.media:media:1.6.0'
Note from official documentation:
With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.
The latest dependencies are:
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.media:media:1.1.0'
def core_version = "1.9.0"
// Java language implementation
implementation "androidx.core:core:$core_version"
// Kotlin
implementation "androidx.core:core-ktx:$core_version"
implementation "androidx.media:media:1.6.0"

Android Studio: Play Services libraries (GCM & Maps) unresolved (errors) but project is working correctly

I'm working on a project. I started with updating the libraries after not touching the project for around a year or so. Updated most of the libraries except implementation 'com.google.android.gms:play-services-maps:9.2.1' and implementation 'com.google.android.gms:play-services-gcm:9.2.1' because there is an older version of a library supplying push for me, which I can't update right now. Anyways, after a while I opened some classes and noticed that for example SupportMapFragment is red and says "Unresolved reference". This happens with every class that comes out of the two libraries. However, the project still runs and still works as expected.
Why is this happening? And how can I fix it?
I will list some other libraries which could have an influence below:
$support_library_version = '27.1.0'
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "com.android.support:recyclerview-v7:$support_library_version"
implementation "com.android.support:cardview-v7:$support_library_version"
implementation "com.android.support:design:$support_library_version"
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true;
}
They got updated from these versions:
$support_library_version = '24.1.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
Crashlytics was not added in previous versions
I was experiencing a similar issue earlier today and used the instructions from this post to fix it:
File->Invalidate Caches/Restart
In addition, it appears that Gradle 3.1.0 doesn't work, but Gradle 2.3.0 does.
Apparently the version I had for GCM and maps was too low. I had to update to a higher version and the unresolved references disappeared. I'm using 11.8.0 right now.

What is the new Implementation keyword in Gradle [duplicate]

This question already has answers here:
Gradle Implementation vs API configuration
(8 answers)
Closed 5 years ago.
I recently updated Android studio to version 3.0. Now in build.gradle all the dependencies are added using the implementation keyword instead of old compile keyword.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.4.0'
}
But the compile keyword still works. What is the difference between compile and Implementation?
compile has been deprecated so use for libraries use api or implementation
Gradle 3.4 introduced new Java Library plugin configurations that allow you to control whether a dependency is published to the compile and runtime classpaths of projects that consume that library. The Android plugin is adopting these new dependency configurations, and migrating large projects to use them can drastically reduce build times.
implementation
if an implementation dependency changes its API, Gradle recompiles only that dependency and the modules that directly depend on it. Most app and test modules should use this configuration.
api
When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time. This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library modules. That's because, if an api dependency changes its external API, Gradle recompiles all modules that have access to that dependency at compile time
Read more from new dependency configurations

Categories

Resources