Cannot import a Library from GitHub into Android Studio - java

I tried to add this library: https://github.com/WojciechZankowski/iextrading4j into android studio, it is a library to retrieve realtime stock data from the IEXTrading API but when I did, or atleast I think I imported it the right way, I got a bunch of errors like MultiDex errors and findbugs:jsr305:1.3.9.
I tried to use the release version 2.1.1, then 2.0.1. Can someone please walk me through the process of how to set it up?
Error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\Ashwin\AndroidStudioProjects\sockettesting\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\USER\AndroidStudioProjects\sockettesting\app\build\intermediates\transforms\desugar\debug\49.jar(;;;;;;**.class)] (Duplicate zip entry [49.jar:javax/inject/Inject.class]))
I've tried searching for answers on how to solve these errors but I got nowhere, I tried multiDexEnable true in gradle and more.

I had a similar problem. I could not get the iextrading4j library to work either, even in a blank project. I changed my dependencies entry to this...
implementation group: 'pl.zankowski', name: 'iextrading4j', version: '2.3.0', ext: 'pom'
Then it worked just fine!

Related

Cannot resolve symbol 'JsonException' - Json Simple import problem

I want to use Json simple in my project, however I can't get it to work. I tried versions 1.1.0, 3.1.0, 3.1.3, 4.0.0 and every time I do import com.github.cliftonlabs.json_simple.JsonException; I have error Cannot resolve symbol 'JsonException' I use InteliJ, every time I tried a version I went to File> Project Structure and added .jar file. Then I add dependecy compile group: 'com.github.cliftonlabs', name: 'json-simple', version: '3.1.0' into my build.gradle. The error repeats every time. How do I fix this?
I managed to fix the issue, I used
implementation 'com.github.cliftonlabs:json-simple:4.0.0' in build.gradle
and refreshed the gradle build

Getting Androidx library issue even though its not enabled in android project

I am getting this issue
This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.annotation:annotation:1.1.0
I keep getting this error and I have been searching the internet to figure out what is wrong and I cannot find anything
"And I can't use Androidx library in my project "
In many of the answers on SO on this problem it has been suggested to add exclude 'META-INF/DEPENDENCIES' and some other excludes. However none of these worked for me. In my case scenario was like this:
I had added this in dependancies:
implementation 'androidx.annotation:annotation:1.1.0'
And also I had added this in gradle.properties:
android.useAndroidX=true
Both of these I had added, because I was getting build error 'cannot find symbol class Nullable' and it was suggested as solution to this on some of answers like here
However, eventually I landed up in getting error:
More than one file was found with OS independent path 'androidsupportmultidexversion.txt'
No exclude was working for me. Finally I just removed
implementation 'androidx.annotation:annotation:1.1.0'
from build.grdle file.
and finally I got rid of this
( More than one file was found with OS independent path 'androidsupportmultidexversion.txt' )
"More than one file was found with OS..." build error.
I wasted hours of mine.But didn't found solution of this.
Then i just change my project
minSdkVersion 19
to
minSdkVersion 21
And finally i am able to build my apk file without any error

failed parsing overlays - Aapt2 - Android Studio

I'm trying to use dlib in Android Studio for my university's project.
I did import all the .so files that I needed, but I can't import the shape_predictor_68_face_landmarks.dat... (I want to import it as a raw file)
I get AAPT2 error: check logs for details and the Java compiler says failed parsing overlays. Do you know what can I do to fix this ? I've never seen a topic about failed parsing overlays.
I already tried to put android.enableAapt2=false in the gradle.properties and the testOptions in the gradle.build without success...
You can find the build log here : Build log
And the project here : https://github.com/ghysc/Stage
If you need any more information, please let me know.
Thanks for reading.
Cyril G
Using your GitHub project I found out it was a problem with one of the resource files you had - it was too big for AAPT2 to process:
./app/src/main/res/raw/shape_predictor_68_face_landmarks.dat
This was a bug in AAPT2 but it has been fixed recently.
So if you update your android gradle plugin version in your build.gradle file to 3.2.0-alpha11 or newer it all compiles fine:
classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
Huh, actually I just solved this problem in another way.
When I imported the project of tzutalin ( : github.com/tzutalin/dlib-android-app), I changed the name of the package, which is why my program couldn't find where the library where stored !
I re-named the package package com.tzutalin.dlib; for the dlib library and everything is fine now.

What to do as AndroidSlidingUpPanel Library is using some libraries not up to date

I was trying to use AndroidSlidingUpPanel in my app but when I was trying to build the Gradle file is giving me this warning.
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.0.0-alpha1, 23.4.0. Examples include com.android.support:animated-vector-drawable:26.0.0-alpha1 and com.android.support:recyclerview-v7:23.4.0 more...
I have seen the files in GitHub and saw that the file AndroidSlidingUpPanel/library/build.gradle is using a lower version of :
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
which should be something like this:
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:support-annotations:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
When I downloaded the library and imported it as module it was giving error too:
Error:(21, 0) Could not read script
'I:\ANDROID\Android_Studio_Projects\TRYS\Theme3\maven_push.gradle' as it
does not exist.
Open File
Even after copying maven_push.gradle to root it is giving this error:Error:Could not get unknown property 'GROUP' for object of type org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.
So what to do?
open android studio and get to this page
press this part
it will open a drop-down menu press git and then
press clone and your done
You have two options
Post an issue in the library on GitHub and wait for the creator to update.
Add it to your project manually by pulling​ the project from git and update the libraries your self.
Remove lines referring to maven_push.gradle from the build.gradle on the specified project.
Example:
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
apply from: './mvn-push.gradle'
Just comment them out. I've got this solution after going through this

Project Not working after updating to API 23

Can anyone please help me with this? I dont know what does this mean.
To give you a back up I updated my sdk with 23 and then i got 101 errors regarding HTTPClient not being resolved. So i followed this link to remove that then I have this error of which i have no clue where to start with.
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-tools\23.0.1\dx.bat --dex --no-optimize --output F:\sagarDevanga\workspace\AndNrby\app\build\intermediates\dex\debug --input-list=F:\sagarDevanga\workspace\AndNrby\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/apache/http/ConnectionClosedException;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Make sure that your adt supports the version of api that you are running. See this link : https://developer.android.com/tools/support-library/index.html
To fix you should check in libs (.jar) and in your build.gradle if there are some libraries duplicated. This error happen tipicaly when you add a copy of the same library or a library that include a copy of another library that you have already added
Update also your support libs from SDK
Ok I have updated the question's title also so that other people also find it useful.So I will write a detailed answer about how this error occured in my project and the fixes I did and how I finally derived the answer.
1) I updated the SDK and then started to compile my project using the latest api i.e API 23. You can do that by going to File -> Project Structure ->Select your module.
Now in the right hand side window under properties the top two properties can be changed using in the drop down.
Then click on Apply and Ok.
2) So when you do this your app's build.gradle file will look like this. And now everything looks good. It will compile also. But when you run the project you will get a lot of errors by this name Error:(17, 35) error: package org.apache.http.impl.client does not exist Obviously if you are using them in your async tasks.
3) So when i got this error I did a lot of research here and there and then came across this link and added the HTTP CLIENTS jar files in the libs folder and then tried to run the program I ended up with this problem (problem mentioned in the question).
4) So after diggin around I found that the problem was HTTP methods which i used in the Async task were deprecated in the API 23 hence I landed myself in this mess.
5) Then what I did next fixed the problem for me. Refernce given here.
6) In your module's build.gradle file add this line useLibrary 'org.apache.http.legacy' like below.
7) Wait your still not done. Now go to your main build.gradle file and add this line classpath 'com.android.tools.build:gradle:1.3.1' like this . Now build and compile your project everything runs fine.
8) After all this steps the project works fine but I have a doubt in the last pic that i shared which is of the top level build.gradle file. Whether I should keep both the classpaths or just use this classpath 'com.android.tools.build:gradle:1.3.1' and remove the other one. If any one have any idea on this please help.
9) The problem was that they deprecated the HTTP Clients in the Latest Android API 23. Insted of HTTP Client you have to use HttpUrlConnection but if you want to continue using HTTP client for NOW follow the steps above.

Categories

Resources