I have a Android app and now I have to make a SDK form the app. So other apps can use my SDK by just putting a compile time dependency I dont find many sources in Internet can some one please help me in this regard.I am using Andorid Studio
I want to build a SDK similar to MobiHelp SDK see this link : https://github.com/freshdesk/mobihelp-android
If your SDK is an Android-Library, declare
apply plugin: 'com.android.library'
instead of
apply plugin: 'com.android.application'
in the corresponding build.gradle. You will get an .aar-File (Android ARchive) that would need to be refereced from others in order to use your SDK.
If your SDK is a plain-old-java-Library (no Android resources) you also can use Maven to package it as jar.
Related
I want to convert existing android studio app project into an android library and add it as a dependency to new android studio app project.
android studio app project has three android library projects as dependencies along with firebase and Crashlytics integration,
Now i want to convert this entire project into one android library and add it to another android studio app project.
i have tried changing below lines
//from
apply plugin: 'com.android.application'
//to
apply plugin: 'com.android.library'
android library contains google-services.json, and other API keys. so when i add android library as a dependency to new app project, it is only taking modules from android library not google-services.json and other settings
How to solve this issue, Or there is a another process to convert app project to library
You can init Firebase with values in your google-service.json in your code side. So that you can get rid of google-service.json file.
I am integrating GCM into my app, what i did was i have made the configuration file google-services.json and placed it inside the app folder (i am using Android Studio) the resource file is also imported and I am also including the plugin in my build.gradle of application like this
apply plugin: 'com.google.gms.google-services'
the problem is that it is still not resolved. I want to know what is wrong?
I have searched about it and i find this, i have used my project number now there is no error coming up. Is it right way to do? Someone please explain
Take a look at the gradle files of the official google example: https://github.com/googlesamples/google-services/tree/master/android/gcm
You will see you need to do two things:
add
classpath 'com.google.gms:google-services:2.0.0-beta6'
to project gradle build file and
apply plugin: 'com.google.gms.google-services'
at the bottom of module app gradle build file.
I have been using Dexguard for my Android project, and it's been working fine until recently I had to use a another plugin. Because the way the other plugin is built, it is required that the project applies either "com.android.application" or "com.android.library". but since the dexguard plugin is an extension of the com.android.application which got replaced by dexguard, I can't use the other plugins that requires the "android" plugin.
//apply plugin: 'android'
apply plugin: 'dexguard'
Does anyone know if there's a way to get around this? I have contacted the authors of the plugin but it won't be practical to bother every plugin author for a solution.
Reference to my problem:
Dexguard plugin specification
And here's the plugin (android-apt) I'm trying to use that requires plugin: Android and only Android not dexguard.
The latest DexGuard plugin (6.1.03) works alongside the Android plugin (1.0.0), instead of extending it. This should improve its compatibility with other third-party plugins.
I have a question very similar to Gradle build fails looking for Google Play Services in Android Studio
I have a working android project but when I add
compile 'com.google.android.gms:play-services:5.0.77'
I get a gradle build error
Error:Failed to find: com.google.android.gms:play-services:5.2.8
Open File<br>Open in Project Structure dialog
I have added the SDKs through the manager. Other threads have suggested that there might be a second SDK library on the computer causing the issue, but I have not been able to resolve this. I am using a mac (and normally a PC user so please bear with me) and looking at the SDK manager and the project structure dialog both say the SDK is located at:
/Applications/Android Studio.app/sdk
Given they are pointing to the same place it must be some other cause of the error?
Maybe I have a version other than 5.2.8 (although unlikely, as andoid studio says this is the most up to date and I have just updated the SDK)? How can I check the version installed on my machine - its not in the file names?
If you are going to use version 5.2.8 you have to set on your build.gradle
compile 'com.google.android.gms:play-services:5.2.08'
Because it is store on the directory :
ANDROID_SDK_PATH/extras/google/m2repository/com/google/android/gms/play-services/5.2.08
You can use '+' instead '08' and you will be using the last minor version
compile 'com.google.android.gms:play-services:5.2.+'
OK so it looks as though my version number was off and thats all that was causing the problem. If anyone else has this issue check your version number in the AndroidManifest.xml file in the google_play_services_lib directory
There is a problem with the 5.0.77 release version. Change com.google.android.gms:play-services:5.0.77 to com.google.android.gms:play-services:5.0.89 and things will work fine.
Google pulled out 5.0.77 from the Maven repository due to some critical bugs. Read More.
I had a different problem altogether. I'd put the line
apply plugin: 'com.google.gms.google-services'
at the start of the file. Even before:
apply plugin: 'com.android.application'
And had to scratch my head for half an hour.
So the final (working) condition looked like:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
I am currently migrating an Android project from classic IntelliJ IDEA format to Gradle. In my project, there are modules that are using the Android SDK without being Android modules. They are plain Java modules that use the Android SDK instead of a JDK.
How can I achieve that with Gradle?
The approach I can think of is to apply plugin: 'java' and somehow configure the Android SDK as the used JDK or as a dependency. But I don't know how to do it exactly...
I have just revisited Eugen's first hint and "suddenly" it works.
So, basically you need to apply the Java plugin and add Android as a provided dependency.
apply plugin: 'java'
configurations {
provided
}
dependencies {
provided 'com.google.android:android:2.2.1'
}
#Eugen: Maybe you'd like to repost this to receive your credits.