android design library gradle null pointer exception - android

I'm trying to add android.support.design library to my project: All the interesting things in my gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:support-annotations:22.0.0'
compile 'com.android.support:support-v13:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.android.support:cardview-v7:22.1.0'
}
I'm getting
Error:Android Gradle Build Target: java.lang.NullPointerException
When removing com.android.support:design:22.2.0 (and adding back v4 and AppCompat), build is successful.
Another similar issue didn't help me
Notice that i'm building using Intellij 14

I ran the app using android studio and not IntelliJ 14 and got a different error:
`Error:(1) Attribute "insetForeground" has already been defined`
So if someone is running IntelliJ 14, until next update of Intellij 14 I guess It's safer to use android studio 1.3.+ (or at least check for errors using android studio.
If one get the same error.
go to attr.xml and remove declare-styleable name="ScrimInsetsView"
using ctrl-shift-f search for insetF and remove app:insetForeground attribute from all the layout that contains such attribute.
Everything should work OK now

I had exactly the same issue. I guess it comes from an combination of mismatching parameters in grade and your xml resources..
Maybe this will help (for me it did):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'com.android.application'
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
}
Give the build.grade the 1.1.1, too (just in case)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
allprojects {
repositories {
jcenter()
}
}
Hopefully the next sync, clean and rebuild will pass (or fire a meaningful error message like 'color-res blabla not found').
Btw: From time to time my IntelliJ is setting itself to other Java-configs (e.g. Java8 with lambdas) - so "just in case":
Don't forget to check if your project SDK is set up correctly (File > Project-structure > project > choose the SDK).

Related

Class module-info is missing a super type

I am trying to build an android application with some dependencies however one of them is causing this error:
Illegal class file: Class module-info is missing a super type.
The dependency causing the issue is JOML a math library for use with OpenGL.
The dependency is included as
dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')
implementation 'org.joml:joml:1.9.9'
...
}
I am using android studio/gradle version 3.1 and build tools version 27.0.3.
I have tried clean and rebuild and clearing Android Studio cashes.
Another thing to note is that it was compiling fine the other day even with this dependency.
You should use JOML for Android instead of the Java version.
Application build.gradle
buildscript {
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
...
}
...
}
App build.gradle
dependencies {
implementation "org.joml:joml-android:1.9.3-SNAPSHOT"
}

How to declare the dependencies of a library project when those dependencies should be fulfilled by the consuming application?

I'm developing an android library that depends on some third party aars and jars.
Currently, these dependencies are declared in the library module's gradle buildscript like so:
repositories {
flatDir{
dirs 'libs', 'android-libs'
}
}
dependencies{
compile(name: 'threetenabp-1.0.5', ext: 'aar')
compile fileTree(include: ['*.jar'], dir: 'libs')
}
However, this results in the dependencies' classes being built into the aar, potentially causing conflicts when the library is used in an application.
How can I reference these dependencies from my library without actually packaging them into the library?
I have tried changing the declarations from "compile" to "provided" and then compiling the files into the application, but when I do this my library fails to build.
After some reading at https://docs.gradle.org/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies I eventually figured out that using compile fileTree will package the dependencies into the output library. To avoid this, declare each dependency individually, using the following syntax:
dependencies {
compile: name: 'filename-without-extension'
}
And the dependencies will no longer be packaged into the output.
The project making use of the output aar will still need to include the flat-dir repository that holds the jar files, like so:
repositories {
flatDir{
dirs 'libs'
}
}

Android library project can not resolve jitpack dependency

I have an android library uses a module on jitpack, so I change my gradle.build
apply plugin: 'com.android.library'
repositories {
mavenCentral()
// jitpack maven
maven {
url "https://jitpack.io"
}
}
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.3.0'
// this is the library
compile 'com.github.ybq:Android-SpinKit:1.0.4'
}
But gradle still can't resolve this library
Error:Failed to resolve: com.github.ybq:Android-SpinKit:1.0.4
Did I missed something ?
A simple answer is that this library is not available in the gradle. Kindly recheck if you are spelling this dependency correctly. This library might be removed by the provider so its not working.
Works fine here.
Try running with -i or -d to get more information about what is happening.
Or maybe now it works and it was a temporary problem? If so, try running with --refresh-dependencies which makes Gradle forget about whether a repository has a dependency or not and requeries it.

gradle project sync failed android studio

I'm trying to setup nhaarman/ListViewAnimations inside of Android Studio 1.1.0.
From Setup:
Add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
}
yet Android Studio says:
Gradle project sync failed. Basic functionality (e.g. editing,
debugging) will not work properly.
Error:(26, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'X' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
You are adding these dependencies in the top level build.gradle file.
You have to add these lines in the module build.gradle file.
root
build.gradle //top level
app
build.gradle //module level
After adding those lines to:
build.gradle (Module: app)
instead of
build.gradle (Project: app)
the error is gone.
Try this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'
}
Try removing #arr. worked for me.
//ListView Animations
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'

Android Ormlite: java.lang.NoClassDefFoundError

I am using ormlite in an Android project from Android Studio. I have configured Gradle to use it from Maven, like so:
dependencies {
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
However, when I launch the app it's giving NoClassDefFoundError for all ormlite classes. The same works if it is done by copying the jars to "libs/" folder.
Any idea why adding them from Maven doesn't work?
Try this on build.gradle:
dependencies {
compile 'com.j256.ormlite:ormlite-android:4.48'
...
}
The ormlite-core is a dependency that gradle will resolve by it's self. After editing, sync and rebuild you app, it should work.
If you want to put jar files in you libs folder, than your dependecies line from build.gradle will look like this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
}

Categories

Resources