error :the package com.badlogic.gdx does not exist - android

I receive the "error :the package com.badlogic.gdx does not exist" when you try to start the project.
In my project there is a libGDX. Classes see it and objects from this libGDX are used. But when trying to compile an application, this error occurs.
At the same time, there are no errors in the classes on which this error is made.
"Sync Project with Gradle Files" and "Invalidate caches/restart" did not help.
Someone came across similar? How to fix this?
enter image description here

Go to libs folder, right-click on libraries you want then select: Add as library
The reason is, you should add the external libraries on Build.Gradle if the online source from maven-jcenter or etc is not available and you have to add them manually.
After doing this, try rebuild the project then you're good to go.
Or in code: (in not added cases by IDE)
implementation fileTree(dir: 'libs', include: ['*.jar'])
Replace the name instead of * in above code.
How to add a jar in External Libraries in android studio
And: How to add a jar in External Libraries in android studio

Related

I cannot import ksoap2 at my class

I have Android Project in which I want to use ksoap2.
I paste the .jar (ksoap2) in my folder libs, then right click on and go ahead to "Add as Library".
enter image description here
After I sync my gradle, Android Studio update dependencies in file build.gradle, like this:
compile files('libs/ksoap2-android-assembly-3.6.1.jar')
Finally in my class MainActiviy.java I want to type import org.ksoap2.Envelope, the IDE doesn't recognize the class ksoap2.
What is wrong with mi procedure?
Best regards.
You just need to paste .jar in your libs and add this in your build.gradle(app)
compile fileTree(dir: 'libs', include: ['*.jar'])
Then Sync.
The problem was that I pasted the .jar file in libs directly in file browser/finder. The correct way is paste the .jar in libs through de Android Studio.
In file browser/finder where .jar file it's, right click and copy.
In Android Studio, Project tab select "Project" to see complete structure. Then you can see libs folder.
Right click on libs folder and go ahead "Paste As Library"
Android Studio creates the correct structure.

Jtransforms use in Android studio 2.3.2

I am trying to use jtransforms in my project. I am new to android studio. I added the jatransoforms-with-dependencies.jar file as a new module.
Some other posts suggested to add jtransforms jar to the libs folder but there are many libs folders when I did a search and none of them show in the left hand side of the android studio dialog box (which shows the programs).
Now they also asked to do this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
}
The above two steps I could not do so I added the jar as a module from right clicking on the dialog box on the left side which shows project names. Now I am unable to delete the module (also please tell me how to remove this).
So lastly when I did this
import org.jtransforms.fft.DoubleFFT_1D;
it says "cannot resolve symbol DoubleFFT_1D".
There are many posts online to add a .jar file but and are varied (depend upon editor / studio version etc). Please tell me how do I add (and remove) the jar file to my project, use jtransforms FFT function.( i read other posts but were not useful).

Adding features to my android project

I am new to android, and I started a project in android studio.
I found an interesting animation, which I would like to use, and perhaps edit in my project, it can be found here https://github.com/booncol/Pulsator4Droid
Now I wonder, how can I use this? I find the description on github hard to understand, I know that AS uses gradle to build, but where in the gradle file should I add the compile? And should I download some additional java files? And should I change my xml files?
I tried searching SO for answers, but one of the most relevant answers was about downloading a jar file, but there is no jar file to download in this case!
Thanx in advance.
You should add the compile line to your module gradle (under the mobile app folder) dependency section, something like this (ordering of the dependencies doesn't matter)
dependencies {
... other stuff may be here
compile 'pl.bclogic:pulsator4droid:1.0.3'
}
This will automatically download the java jar files required when you build.
Then where you want to use the pulsar control just add it to your activity xml file as specified in the projects readme under the usage section.
Add compile 'pl.bclogic:pulsator4droid:1.0.3' this in your app level gradle file

Android studio add libs

I use "add as library" in Android studio, and it sets "compile files('libs/XXX.jar')" in "build.gradle". But it doesn't work!!!
It cost lots of my time. At last, I modify to "compile files('XXX.jar')"
But my jar is in directory "libs" as picture shows: libs Picture
Please tell me why!
Here is the supplement picture of build.gradle
Try adding compile fileTree(dir: 'libs', include: ['*.jar']) to your Gradle file and tell me if it worked :)
edit
or does it work but you don't understand why it works like this? Then it automatically assumes that your libraries are placed in that directory so you don't need to specify the libs/xxx.jar because it knows it should look in that directory anyways, so then it would search for libs/libs/xxx.jar instead of libs/xxx.jar. Hope that makes sense
In Android Studio click on Project Structure button to the right of Run Button,then click on the green + icon in the top right,choose Android Import Exiting Project[if the lib is .jar of .AAR choose Import . JAR or .AAR]then choose the lib and click finish,wait for gradle sync,then add the compile.Wish this helps

Auto link source code downloaded by Gradle

Sorry if this question is duplicated but I have searched for a while and couldn't find the answer.
I use Android Studio and Gradle to develop my app, gralde will auto download source code from maven but then inside Android Studio it's said that "Sources Not Found" and I have to drag drop or select the source files directly. This is very troublesome. Is there anyway that AS auto link the sources downloaded with the class, and when I ctrl + click on the class it will open the source file directly?
Edit: Some libraries like ButterKnife I can view source code directly, but others like MaterialEditext I have to select the source file manually.
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.rengwuxian.materialedittext:library:2.0.3'
ButterKnife can be found in External Library while MaterialEditext isn't. I don't know why.
Not every module you want can be selected automatically. Only those you can find in dependencies could be imported by Gradle. Take a look here:right-click at your project --->Open Module Settings--->Modules--->Dependencies--->Plus--->Library Dependency, and then you can select one Library Dependency. And then it will be added into your project by Gradle. Most importantly, What You Can See Is What You Can Get. If you can't see the module you want, maybe you need to download it somewhere else.

Categories

Resources