I created an Android library that uses JavaPoet to generate classes. It works well on my local workspace ; even if I include the library module into another project.
Now I'm trying to put my project online through bintray. The project is uploaded correctly, but then when I include it in a new project and build the projet I get this message :
Error:Bad service configuration file, or exception thrown while
constructing Processor object: javax.annotation.processing.Processor:
Provider me.aflak.filter_processor.FilterProcessor could not be
instantiated: java.lang.NoClassDefFoundError:
com/squareup/javapoet/TypeName
I guess it comes from the way I manage the dependencies... Compiletime, Runtime stuff...
This is processor build.gradle :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':filter-annotation')
api 'com.squareup:javapoet:1.9.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.google.auto.service:auto-service:1.0-rc3'
}
This is annotation buid.gradle :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.8.1'
}
This is how I include the library in an empty project :
// build.gradle project
repositories {
maven{
url 'https://dl.bintray.com/omaflak/maven'
}
}
// build.gradle module
dependencies {
compile 'me.aflak.libraries:filter-annotation:1.0'
annotationProcessor 'me.aflak.libraries:filter-processor:1.0'
}
Could someone point me out to the right direction ? Thanks !
I finally got the solution (a bit randomly though :p).
I had to add mavenLocal() in the library module.
Related
I recently migrated from Eclipse to Android Studio and I'm using Android Studio 1.5.1. Before when I started Android Studio, I got this error:
Failed to resolve: junit:junit:4.12
After searching in Google and trying some proposed options, only commenting junit test in app/build.gradle solved the problem:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
}
But I want to know is this a good and safe option to resolve that problem? For example does it cause any problem in future?
You will need to add the following to your build.gradle file and it should work fine.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
I created a new library module to my project in Android Studio. A class in this new module accesses org.json.JSONObject.
I'm getting the error:
failed to resolve org.json:json:20141113
when trying to build the project.
Here's how my build.gradle file looks:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':app')
compile files('libs/volley.jar')
compile 'org.json:json:20141113'
}
Please let me know if I'm missing anything.
Thanks.
Try adding a repository to your configuration maybe that helps.
repositories {
mavenCentral()
}
For more information see here:
User-guide: Dependency Management Basics
Test This one , Worked for me
dependencies {
implementation 'com.cedarsoftware:json-io:4.10.1'
}
I am following the post : post
but after following that post still I am encounter into error :
Could not find method
org.androidannotations.api.view.OnViewChangedNotifier.replaceNotifier,
referenced from method MyClass_.getInstance_
My library uses Android Annotations as DI/IoC.
My library module dependencies in .gradle file are :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
apt "org.androidannotations:androidannotations:3.+"
compile "org.androidannotations:androidannotations-api:3.+"
testCompile "junit:junit:4.12"
}
My host App module dependencies in .gradle file are :
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile(name: 'my-lib', ext: 'aar') // NOT WORKING
}
OR
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile project(':my-lib') // NOT WORKING
}
P.S. The problem is the Test(host/client) app does not recognizes the AA dependency. So you need to add the AA dependency explicitly into the Test app and it works like charm.
But I want to give only my library's AAR archive file to client, so it can be directly used into its app without adding AA dependency. To add the AA jars directly into library module I followed the AA configure guide for Android Studio : AA Configure Guide after this still I got the error for the library module which fails to create the AAR archive. The call to internal methods does not recognized by the library. MyClass_.getInstance_(context); Shows me something like :
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: MyClass.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
I am working on a simple login android application in android studio with parse. Just a few backs I switched in to studioo from ecclipse so I am not much familier with that. I am refering the following tutorial.parse tutorial
I have done everything as they mentioned. Added parse.jar[add in to libs folder and settings file updated ] and update app gradile file.
But when I tried to run the application , it crashes.java.lang.NoClassDefFoundError: com.parse.ParseUser.
If anybody have any idea about my issue please help me to solve it. I didn't find any similar questions thats why posting.
My app gradile file have below lines.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
} and we can't add dependencies to outer [main] gradile file..right?...there is
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Have you added a compile command to your build.gradle file?
For example:
compile fileTree(dir: 'libs', include: ['*.jar'])
So, I managed to create an Android library component and publish it on Maven Central. But when I'm trying to use it as a dependency in a new project, Android Studio can't seem to find the classes.
build.gradle for the app module:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'no.hyper:libdateintervalpicker:1.0.0' //this is the one I want to use
}
This part seems to work, at least I get no sync errors. However, when trying to access to package and classes from my MainActivity, Android Studio can't find them and gives me "cannot resolve symbol" message.
I have tried downloading the classes.jar from the archive directly from Maven Central, and they are indeed in the package.
Other dependencies seem to appear in the /build/intermediates/exploded-aar folder after syncing, but that does not happen to my library.
I use Android Studio 1.0.2 on OSX 10.9.5 (Mavericks)
Any suggestions?
Looking in your pom, it states <packaging>aar.asc</packaging>. It should be aar instead.
Oh, and the answer to actually being able to use the library, was to add #aar to the dependency so that it now reads
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'no.hyper:libdateintervalpicker:1.0.0#aar' //note the magic #aar
}
Edit:
Removing the block
configurations {
archives {
extendsFrom configurations.default
}
}
makes Gradle generate the pom with the correct packaging entry, and thus makes it possible to reference the dependency without the #aar suffix