I DO NOT have an android app grade file. I am creating a flutter plugin and would like to use a .aar library in the plugin. All online resources and answers are suggesting to add the follow to the app gradle:
compile fileTree(dir: 'libs', include: ['*.aar'])
or
implementation files('libs/library-name.aar')
is it possible to include the aar without going to an android plugin (not an app)?
Related
I want to add Cordova to my existing android app. Please tell Where is the framework folder in android used for external Jar file?
if you are using android studio you can add this to your gradle dependencies:
compile fileTree(dir: 'libs', include: ['*.jar'])
then it would be $ProjectDir/libs/your.jar
I'm trying to migrate an Android project developed with Eclipse ADT to Android Studio. I've already read the instructions mentioned here http://developer.android.com/sdk/installing/migrate.html and it works fine!
Gradle builds a new android project but I need to "hardcode"(modify manually) the gradle.build file in order to make the libraries work properly. All the other stuffs work fine.
This is the ADT project
MyApplication/
-->assets/
-->libs/
---->android-support-v7-appcompat.jar
---->android-support-design.jar
-->res/
-->src/
-->AndroidManifest.xml
-->project.properties
The first library is automatically recognized by Gradle, and it is substituted with
compile 'com.android.support:appcompat-v7:23.2.1'
in the grandle.build file.
Instead the "android-support-design.jar" is not recognized and it is added to the gradle.build as
compile file('libs/android-support-design.jar')
but it is not working at all.
At the moment, I need to manually substitute the
compile file('libs/android-support-design.jar')
with
compile 'com.android.support:design:23.2.1'
In order to make the build work effectively.
Is there any way to force Gradle to recognize that library and automatically import it? Can I download a version of that library that is recognized, anywhere? At the moment I'm taking both libraries from
<sdk>/extras/android/support/
Thank you all.
I need to "hardcode" the gradle.build file in order to make the libraries work properly
I'm not sure what you mean by "recognize" and "hardcode", but if you just have jar files that you can't use the compile line like for the support libraries, then you can use this line, which will take any jar file in the libs/ folder and compile it. You don't need to hard-code any of those.
compile fileTree(dir: 'libs', include: ['*.jar'])
Otherwise, you should already have these.
compile "com.android.support:appcompat-v7:23.2.1"
compile "com.android.support:design:23.2.1"
But, if you want to get fancy with Gradle, you can do something like this to keep all the support libraries the same version.
ext {
supportLibVersion = '23.2.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
I have made an AAR using Android Studio and I can successfully use it in any app. Problem is I have to add all the dependencies it needs manually to the app build.gradle (like compile 'org.slf4j:slf4j-android:1.7.10').
I want the AAR to actually include all these third-party dependencies it requires so I won't have to add them manually in the app. Is there a way you would know of?
If you use
compile fileTree(dir: 'libs', include: ['*.jar'])
and put a jar in libs folder, this jar will be included in the AAR.
But you have to put the jar yourself.
As far as I know, there is no way to put a repository dependency inside an AAR.
I'm using the gradle build script, in android studio to fetch the Parse android SDK, as follow:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
}
The build process succeeds with no errors, yet , when I the to import com.parse.Parse; I get cannot resolve symbol parse.
To my understanding, that build script was supposed to download the Parse SDK from a maven repository, and build it, or otherwise to fail.
Where do I have wrong?
Check Parse's Android Studio guide again, you'll see this:
Step 1 instructs you to download the SDK.
Step 2 asks you to first put Parse-*.java to the project's libs folder, and then add the script you've shown in your question into build.gradle. Notice that the library pulled from maven is just an auxiliary library, not the Parse library itself. This is why Android Studio cannot find the Parse class.
I'm trying to add a Leader Board to a Chrome cast project and am getting errors. Android project in Android Studio. In my gradle build - Error: more than one library with package name 'com.google.android.gms'
I understand why you don't want to use two different libraries with the same name, but not sure how to use the same library throughout the project. Here are the two uses of gms:
1) Main activity has dependency on 'CastCompanionLibrary-android-master' which then uses google-play-services_lib. I'm not sure which version of gms this uses, but the version number is referenced in the manifest. Is this just grabbing the version # of play services that they have installed on their phone?
2) BaseGameUtils - has dependency on com.google.android.gms:play-services:+ (I think this is grabbing the most recent version of play-services, but doesn't match the other one.
MainActivity gradle file
dependencies {
compile project(':BaseGameUtils')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CastCompanionLibrary-android-master')
}
CastCompanionLibrary-android-master dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
compile project(':android-support-v7-mediarouter')
compile project(':google-play-services_lib')
}
BaseGameUtils dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:+'
}
So, the problem (I think) is these two versions of com.google.android.gms, but how do I rectify it so that they all use the same version. I've had almost 2 years of working with Android, but this is my first question on stack overflow. Help is appreciated - Is there a guru out there that has the answer to this?
Seems like you have modified the gradle file for CCL since what you have there does not match with what CCL has in GitHub. The best approach is to only use the piece of play services that you need; for example CCL only needs the play-services-cast (besides the base, which will be pulled in automatically) so if you follow that pattern, things would look smaller (less possibility of running into the 64K dex limit) and less collisions.CCL, in Github, lists its dependency as:
compile 'com.google.android.gms:play-services-cast:6.5+' so you might want to start using versions and also follow the recomendation I just made (same applies for any other code that you have and uses play services; just pull in what you really need)