I am getting this error when using an import method I found to Android Studio.
https://github.com/MagicMicky/FreemiumLibrary/wiki/Import-the-library-in-Android-Studio
The import method I am using is in the above link.
This is the error message (Click Here)
This is how it is in the settings.gradle
include ':app',':lib:json-simple-master'
and this is how I edited the build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
compile project(':lib:json-simple-master')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
This is how I am trying to import the file
import org.json.simple.*;
You shouldn't need to follow those instructions
But you edited the wrong build.gradle file.
Update the one like this
android {
...
}
dependencies {
...
compile group: 'com.magicmicky.freemiumlibrary', name: 'library', version: '1.1'
}
If you want a JSON library, android already has org.json... If you want Java object deserialization, use Jackson or Gson.
json-simple doesn't seem necessary in an app
Related
So I've tried adding Firebase dependency to my gradle project. But it doesn't seem to be working. It adds fine, there's no errors or anything and I can see the firebase jar in my Referenced Libraries. But whenever I try to import anything from it like import google.com.firebase, it doesn't show up. What am I doing wrong? These are the only imports I'm seeing.
This is my repositories thing in build.gradle
repositories {
mavenCentral()
google()
jcenter()
}
This is my dependencies thing
dependencies {
compile 'com.google.firebase:firebase-database:19.3.1'
}
So basically, the dependency adds correctly I think, it does show up on the Referenced libraries on my IDE but I don't know why I cannot access it?
Btw I'm not making an Android app, it's a mod for minecraft that uses forge gradle.
Also this is my gradle version: https://services.gradle.org/distributions/gradle-4.1-all.zip
It was because i used an dependency meant for android developers with the aar extensions so instead of using
compile 'com.google.firebase:firebase-database:19.3.1'
In dependencies in build.gradle using this which is meant for the java thing works now.
compile 'com.google.firebase:firebase-admin:6.16.0'
I am trying to break parts of my app out into a reusable module.
Now, a class in my module that is trying to import android.bluetooth.BluetoothDevice cannot resolve the symbol.
Here is my gradle script for the module:
apply plugin: 'java'
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/Android_Platform_Adapter.jar')
compile files('libs/wisepadapi-android-2.7.0.jar')
compile files('libs/emvswipeapi-android-2.12.3.jar')
}
This is the first module I've worked on. I'm sure it's something easy. Thanks!
Here is the mismatch. You are trying to import import android.bluetooth.BluetoothDevice inside a strictly java module (apply plugin: 'java').
You should create android library module. Create a new Phone & Tablet module as described here.
I'm following along with this tutorial for using Overlap2D with LibGDX. As part of the tutorial, I'm adding the Overlap2D runtime to my dependencies in Gradle. Following the instructions on the runtime's website, which say
If you are using gradle, yo can just add this line to your dependecies:
compile "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.2-SNAPSHOT
I've added the following to my build.gradle:
// snip...
project(":core") {
apply plugin: "java"
dependencies {
compile "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.2-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
}
}
//snip...
In my LibGDX project, there are multiple autogenerated build.gradle files. I've made this change to the build.gradle file in the root of the project.
Then, directly copying code from the tutorial I'm following, I try to use the Overlap2D runtime library in one of my classes:
import com.uwsoft.editor.renderer.Overlap2DStage;
public class GameStage extends Overlap2DStage {
}
Compiling this class fails:
GameStage.java:3: error: cannot find symbol
public class GameStage extends Overlap2DStage {
^
symbol: class Overlap2DStage
Why can't my project see the classes from my Gradle dependency? Have I not added the dependency to my project correctly?
I'm using NetBeans, but compiling the project fails from the command line too, so I don't believe my IDE is the cause of the problem I'm having.
The tutorial I was following is out of date. The Overlap2DStage class I was trying to use is no longer a part of the Overlap2D library at all!
If you were following that tutorial as well, Overlap2D now has a video tutorial that is more up to date here: https://www.youtube.com/watch?v=bhvHm2sM0qo&feature=youtu.be
Follow the video tutorial instead.
I am having a problem with Android Studio recognizing classes inside an #aar library imported locally.
So... I've made a library and exported is an aar file. Inside android studio I selected Import Module and them Import .JAR or .AAR Package.
The project compiles and works with the classes inside the aar file but Android studio can not find the classes or offer any auto completion of so all.
Here is a few of screenshots:
The same problem also happens with other #aar libraries imported the same way:
Any suggestions?
Edit:
build.gradle:
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':UpPlatformSdk')
compile project(':simpleorm')
... // more libraries here
}
settings.gradle:
include ':app', ':UpPlatformSdk', ':wear', ':simpleorm'
Looks like you could do this How to manually include external aar package using new Gradle Android Build System
If you have them in your lib folder
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'UpPlatformSdk', ext:'aar')
}
This may not be the quickest way, but this works for autocompletion and also solved my problem of missing classes when I tried compiling my local AAR using the method #puj described. Essentially you need to create a local Maven repository to host the AAR, but any changes you make are pulled by the build system when you do a Gradle sync.
Android Library AAR depending on another library
I am trying to add the Parse SDK into my app. Here is the steps I took:
Dragged all Parse files into my libs folder
Add the following lines to my code:
import com.parse.Parse;
import com.parse.ParseAnalytics;
Went to my build.gradle and added:
compile files('libs/Parse-1.4.1-javadoc/Parse-1.4.1.jar')
However I am still getting these errors:
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Change compile files('libs/Parse-1.4.1-javadoc/Parse-1.4.1.jar') to compile files('libs/Parse-1.4.1.jar')
If you see your jar file in explorer on the left side, click right button of your mouse and then 'Add as Library'. It just helped me.
I added the Parse-SDK into my app as follows:
Dependency: Add this in your root build.gradle file (not your module build.gradle file):
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Then, add the library to your project build.gradle
dependencies {
implementation "com.github.parse-community.Parse-SDK-Android:parse:*latest.version.here*"
// for FCM Push support (optional)
implementation "com.github.parse-community.Parse-SDK-Android:fcm:*latest.version.here*"
// for Kotlin extensions support (optional)
implementation "com.github.parse-community.Parse-SDK-Android:ktx:*latest.version.here*"
}
replacing latest.version.here with the latest released version (in my case 1.18.5).
More details here: https://github.com/parse-community/Parse-SDK-Android/.
I am not to sure if that achieves the same purpose as what you wanted.