I am using unity3d in my android studio project and need to import the unity ads aar file into my project. To do so I added the following lines and the unity-ads.aar to the libs folder :
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation files('libs/unity-ads.aar')
I get the following error when I compile the project :
Duplicate class com.unity3d.ads.BuildConfig found in modules jetified-unity-ads-4.2.1-runtime (com.unity3d.ads:unity-ads:4.2.1) and jetified-unity-ads-runtime (unity-ads.aar)
If I delete these lines and the unity-ads.aar file all the classes from unity3d aren't recogonized and I get errors.
I don't understand why the classes are duplicated and how I can resolve this issue.
You only need the first line
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
and make sure you update your gradle version to 7.x.x
file -> Project Structure
Related
I know how to work with Apache Commons Lang 3 library in an Android Studio app by implementing it in the build.gradle file using implementation 'org.apache.commons:commons-lang3:3.12.0'. But I want to know if it's possible to include the Apache Commons Lang 3 library (or for that matter, any external library) in the Android app manually if I have the library downloaded on my PC? For example, like adding the .jar file of the library to Android Studio or something of that sort.
I'm asking from the viewpoint where I have a library folder in my PC which doesn't have an online link from which gradle can download and merge it with the Android Studio app automatically. How do I add that library to my Android app? Any elucidation on this matter is complimented.
Regards
These are the steps to add a local library as dependency (.jar):
put the jar file into "libs" folder
add the following line to your build.gradle, inside dependencies:
compile fileTree(dir: 'libs', include: ['*.jar'])
like:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Options in the links listed below actually helped me to achieve my objective properly:
https://www.geeksforgeeks.org/how-to-import-external-jar-files-in-android-studio/
https://medium.com/#jonathanmonga/how-to-add-libraries-in-android-studio-in-english-286db8b073c2
i found lot of FFT library on github but i don't know how to add them to my project.
I try to import it without success.
Can you help?
Here what i found:
1) https://sites.google.com/site/piotrwendykier/software/jtransforms
2) https://github.com/wendykierp/JTransforms
If your project has a libs folder for external dependencies then you are good. Else create one under the main project. If you have the jar with all dependencies for the FFT algorithm, put it in the above mentioned libs folder. Next open build.gradle under app and add the following line under dependencies if it not already there..:
compile fileTree(dir: 'libs', include: ['*.jar'])
Sync the project as you usually do.
I am working on integrating twitter with my android application, I am using twitter4j library to do this.
I have added the twitter4j library files and put it in a folder libs and added compile dependency in build.gradle inside app folder
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'org.twitter4j:twitter4j-core:4.0.2'
}
but I am still not able to use this library
In the Gradle drawer to the right, could you hit the refresh button to see if that helps? Also, the dependencies block that you've pasted above doesn't contain a directive for twitter4j - did you happen to simply miss it out in the question, or is it really missing from the gradle.build file?
Try to add this at "repositories" on your buildscript.
repositories { mavenCentral() }
I'm doing the beginner android course on udacity and the code that they make you put in the MainActivity.java file is full of errors and keeps saying build failed in the console. Here is a link to a screenshot of android studio after failed build
http://postimg.org/image/6etcu6ldz/
I think support library is missing.
Go to your build.gradle (Module:app) and check if support library is in dependencies section.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
}
In addition, you have to install it in SDK Manager.
I hope this answer will help you!
I just downloaded the file jdom-2.0.5.zip so I can make my apps manipulate xml files, the thing is, I don't know where to place it or how to install it.
You can unzip the "zip" file and move it to the "libs" folder the jar file of your project in Android Studio.
Check if you have in your gradle this code line:
compile fileTree(dir: 'libs', include: ['*.jar'])