android, why published to local maven does not produce the transitive dependency - android-gradle-plugin

Having a android library which has some transitive dependencies.
api 'com.squareup.retrofit2:retrofit:2.9.0'
api 'com.squareup.retrofit2:converter-gson:2.9.0'
api "com.squareup.okhttp3:okhttp:4.10.0"
and with
id 'maven-publish'
and
repositories {
mavenLocal()
google()
mavenCentral()
}
it can do publishToLocalMaven.
but when using this library in app, the app crashes with
NoClassDefFoundError: Failed resolution of: Lretrofit2/Retrofit$Builder
It has to add those dependencies directly in the app (which it is supposed to get from the library's api transitive dependencies).
Why the transitive api dependency is missing in the app that uses this library?

Related

add third party library to kotlin multiplatform mobile shared module

Am writing a KMM mobile app that will be calling an AppSync API, my intention was to implement all the API calls in the shared module so that I don't have to write that code twice (i.e for iOS and Android separately)
Secondly, I want to use the Amplify libraries in the shared module to implement the API calls, am hoping this would allow me to take advantage of lots of features such as offline storage.
What I am noticing however is that even though I have successfully added the amplify libraries in the commonMain sourceSet, the libraries are not visible on the classpath so i can not import any class from the libraries
Here is my commonMain sourceSet dependencies in the build.gradle
val commonMain by getting {
dependencies {
implementation("com.amplifyframework:core:1.35.2")
implementation("com.amplifyframework:aws-api:1.35.2")
}
}
This builds successfully and installs the dependencies but i can't import anything
My question here is,
Does this mean that I can not add any third party that is not a kotlin multiplatform library at all?
I feel like the only option this leaves me is to implement the API calls twice in a platform-specific way which kind of defeats the purpose of using KMM completely, is there an alternative solution that could allow me to use these libraries and write the API calls as shared code that is imported to both iOS and Android apps?
Thank you
I have decided to use https://www.apollographql.com/docs/kotlin/v2/essentials/get-started-multiplatform.
This seems to work well with the KMM, I can build the API calls once and re-use for both platforms.

Kotlin Multiplatform Mobile library structure

Some time ago I've created a KMM library from IntelliJ IDEA, using the "Mobile Application" project template. The structure was (with one root build.gradle.kts file):
libraryProject
- build.gradle.kts
- src
- androidMain
- commonMain
- iosMain
Now, that template is missing from the list. There is just a "Library", which creates a jvm/js/common/native structure.
In Android Studio, the KMM plugin generates (for KMM library template):
libraryProject
- build.gradle.kts
- settings.gradle.kts
- libraryShared (this can be renamed)
- build.gradle.kts
- src
- androidMain
- commonMain
- iosMain
This is just a KMM application without the actual iOS and Android platform modules.
And, it comes with two build.gradle.kts files (root and shared).
I'm just curious if I missed anything or do I have to configure it manually, somehow.
All IDEs and plugins are up-to-date.
When creating new project in Android Studio, one should be able to choose between two KMM projects(KMM Plugin is required to be installed):
KMM Library which contains only the shared module defined, and is intended to be used when one wants to add this library into existing iOS and Android apps.
KMM Application which creates a complete project with shared multiplatforn library, iOS app with ready integration, and the Android app.
Probably, in this case these two were confused. If you had only one option in the Wizard, please let me know which IDE and Plugin versions were used.Note: Mobile library and Mobile Application were removed from IDEA by design,please see https://youtrack.jetbrains.com/issue/KTIJ-19232.

The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0

When I sync my react native project in android studio I got those warnings
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0.
I got those warnings for multiple libraries like
#react-native-community\masked-view
react-native-firebase_app
react-native-firebase_auth
Although I replace jcenter() with mavenCentral() in my main gradle.
So My question is that How I replace jcenter() with mavenCentral() in all my node modules libraries because I Think it's not a right way to just go in all libraries one by one and replace. Currently I am using gradle 7.0.2

react-native-maps production: app crashes when opening basic <Mapview/>

I am unable to integrate react-natives-maps in a production build as I am unsure how to set it up with expo and react native 0.61.
Am I supposed to create a android/build.gradle file to make this work? Till now I wasn't needing this file as everything is handled by expo. I also don't have any other files in the android/ folder. This is the build.gradle that I have added:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'de.undercouch:gradle-download-task:4.0.0'
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
but I am actually unsure whether this file is used at all when I run expo build:android.
I have created the gradle file according to the installation instructions here, specifically for the 0.61 version.
When I open the APK-file after running expo build:android the screen simply crashes which make me think somehow react-native-maps is not linked properly. I am not getting any error as the app simply restart.
Depending on how you have created your react-native project with Expo will determine what folders are available and how you install dependencies.
By default Expo abstracts away the native iOS and Android code so that you do not have to worry about it.
As you project does not have and ios and android folders, this means that you are using a managed workflow which means you cannot install dependencies that add native code.
Expo provides MapView which is what you are looking for. You can install it by following the instructions here.
Basically, as you are using a managed workflow, you should use:
expo install react-native-maps
You shouldn't be adding ios or android folders to a managed workflow application as that won't do anything.

Cordova CLI build gradle error : java.lang.NoClassDefFoundError: com/android/build/gradle/internal/ToolingRegistryProvider

i follow steps based on cordova installation instruction
here.
but when i want to build a hello project, it gives me following error :
java.lang.NoClassDefFoundError: com/android/build/gradle/internal/ToolingRegistryProvider
does anyone knows what's went wrong?
additional info :
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed Google Inc.:Google APIs:24,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:15,android-26,android-25,android-24,android-23,android-22,android-21,android-19,android-15,android-14
Gradle: installed D:\gradle\gradle-4.4.1\bin\gradle
https://i.stack.imgur.com/j9JFA.png
#kmno, try this in your build.gradle to see if it works. (Android dependencies)
allprojects {
repositories {
google()
jcenter()
}
}