I've been trying to do get the gamebaseutil into my project.. I switched from eclipse to android studios 'cause it seemed impossible to import it in Eclipse.. Now I don't understand the importing of android studios very well so I'm still trying to import and use it..I have really no idea what i do wrong or what i have to do... I'm pretty sure I imported GameBaseUtil into android studios but now I want to make use of it in my project.. I have added " include '(:libraries):BaseGameUtils', ':Name' " to my settings.gradle.. and when I run it, there are no gradle build errors but still I can't instantiate "GameHelper mHelper;" for example. Or "extends GameBaseActivity"
Please tell me what to do. I'm really desperate 'cause I have been reading and trying the whole day...
Including the lib in gradle.settings is the first step.
The next step is to add the lib as a dependency of your main project (in the build.gradle):
If you have the sources of the library :
dependencies {
compile project(':GameBaseUtil')
...
}
If your library is in a maven repository :
dependencies {
compile '<groupid>:<artifactid>:<version>'
...
}
there other ways to define a dependency : here
Related
I'm trying to create an app for android (google Tango) that uses thrift to send some information to a client. I take a sample Tango app which runs without Thrift. Then when I add try to add some of the Thrift dependencies (like slf4j-log4j12-1.7.12.jar) I suddenly get errors like
error: package com.google.atap.tangoservice does not exist
I don't get what's wrong, it worked before...
Why does this happen, and how can I fix it?
Thank you
UPDATE
The way I added the library was by clicking right on App>new>module then I chose import jar, and selected the jar. Then I went to project structure and in dependencies I added the module of the jar I imported.
Adding it like this did not help me resolve the conflicts I had before:
import org.slf4j.Logger;
giving me the error "cannot resolve symbol 'Logger'".
And it also introduced the errors previously mentioned.
Have you tried adding a dependency to your build.gradle file like this:
dependencies {
compile 'com.google.atap.tangoservice'
}
If you are using local jar dependency then add it like this to the build.gradle:
dependencies {
compile files('libs/something_local.jar')
}
I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project?
Here is what I have tried without success:
I downloaded the json-simple-1.1.jar and put it in core/build/libs folder. Could not use import.org.json.simple.JSONObject either.
When browsing the tree in Android Studio as "Packages" dropdown, I can see the classes I want under "Core -> Libraries -> org -> json" but I cannot add them to my project. I get a "cannot refractor, class is in a jar file" error.
Is there something I have not tried yet to solve this issue? I feel I will run into this again as I try to use other external libraries.
Thank you.
If you are using LibGdx, it does not come with a Gradle setup, making multi-project builds streamlined.
You need to add implementation 'org.json:json:<version>' to the dependencies block of your top-level build.gradle.
To find the latest version, see http://mvnrepository.com/artifact/org.json/json/
For example, using the latest version at the time of writing:
dependencies {
implementation 'org.json:json:20200518'
}
I'm migrating from Eclipse over to Android Studio and am looking at the Navigation Drawer example from Google. Right away, I see that I get this warning;
It looks like I need to use the v7 library rather than the v4. I can't figure out how to do this. In Eclipse, I just added a dependency from the build tools, but I see no such option in Android Studio. If I look at the build.gradle file, I can see this:
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
I just downloaded Android Studio yesterday, so I think that I should have this dependency somewhere, but I just don't know how to include it. Can someone tell me how to do this?
From within Android Studio, you can go to File, Project Structure, select your module, and go to the Dependencies tab - you'll see a list of dependencies - you can add new dependencies via the + sign near the bottom of that screen - it will automatically suggest the most popular libraries and all Google libraries including the one you want: appcompat-v7. This controls the build.gradle file and, in your case, adds the line:
compile 'com.android.support:appcompat-v7:21.0.3'
Note that you can also use sites such as Gradle, please to manually figure out what the dependency should be and add it to your build.gradle file yourself if you'd like.
In my project, i have a module abc:
//abc module (lib) dependency
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
And my app's dependency:
dependencies {
compile project(':abc')
}
And the errors are:
“Attribute ”mnp“ has already been defined”
“Attribute ”xyz“ has already been defined”
...
And i found that all these attributes are defined in declare-styleable of module abc and they are quite a lot. I dont know where they produce the duplicate since i can run normally from Eclipse, not Android Studio. Some suggests that to manually rename the attributes of those but I think it is time consuming.
Any better solution? Thank you!
This happens to me as well when I import project from Eclipse. Android Studio seems to binds library project even thou there was an error adding library modules.
I can usually fix this by firstly delete library modules, then opening Project's settings.gradle file and delete imports from there. After this, import of library modules works well.
And when I have issues with styleable file, I can usually fix this by setting SDK version to at least 20 (Android 5.0)
Hey I've been trying for hours to import an Android library (BetterPickers latest commit) into my project using Gradle
After importing and setting it as module, I get compilation errors. It seems like something is wrong with dependencies in my build.gradle .
build.gradle of library project
build.gradle of main project
As you can see, Android Studio suggests an autofix but it's not helpful.
When I try to run the project/Gradle build, I get compilation errors since the library project is dependent on nineolddroids lib. When I try to add nineolddroids to the dependencies I get a different error:
Could not resolve all dependencies for configuration ':sub:bp:_DebugCompile'.
Could not find com.nineoldandroids:library:2.4.0.)
I guess both of them are derived from the same thing.
How can I fix this?
A few remarks
Using latest Android Studio (0.2.5)
Android Support Repository is installed
In the main project, the support lib is imported just fine and I get no compilation errors when using classes from support lib
Tried many ways to import the library project, including answers from here