How to import Material Design on Android Studio project - android

I want to use this Material Design :
https://github.com/navasmdc/MaterialDesignLibrary
I have Imported it into my project and changed version numbers in build.gradle of it to versions of build.gradle of my app
Now there is a build error :
Error:(24, 13) Failed to resolve: com.nineoldandroids:library:2.4.+
I have searched and founded some solutions such as change 2.4.+ to 2.4.0 ! or this link, but they didn`t solve the problem
The question is :
When a project imported, what should be same in imported build.gradle versions and my app build.gradle versions ?!
My project compile in offline mode, Should I disable offline mode and let the Android Studio to download gradle files needed ?

As the link for the library says, do the following in the build.gradle. Copy the compile statement below in the dependencies tag. Your library name was wrong.
repositories {
jcenter()
}
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
}
You will find the dependencies in the build.gradle in the app folder not in the project folder.
You need to disable offline mode. After the library is imported you can go back to offline mode.
About the cannot resolve error:
nineoldandroid library is very old and now deprecated. I believe the material design library is using NineoldAndroid library. For some reason, it not able download this library. Why don't you add the nineoldandroid library first. If the material design library finds it then it may not try to download it.

Related

Error:(44, 13) Failed to resolve: org.achartengine:achartengine:1.2.0 [duplicate]

I have to create an application that makes extensive use of charts.
Reading the web I chose achartengine that seems to have everything I need.
I downloaded the jar file, I plugged in the libs folder, I selected "add to library" and I lunch the gradlew clean.
Result in the sources where I do the import of org.achartengine.xxxx I always returned the error that fails to resolve symbols .
Do you have suggestions?
Thank you
Andrea
I am able to use this library in my Android Studio project, this topic explains how to add AChartEngine repo to your project.
What I did:
Added following to project-wide build.gradle (one from the project root):
allprojects {
repositories {
...
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
For every module that uses the library, add this to its build.gradle (you may put this to the top-level build.gradle if it should be included in all modules):
dependencies {
...
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'
}
Now I can use the library in the project, I see the classes in code assist popups and build runs as succeeds.
It seems like the new version (1.2.0) is not available for download anymore in the http://www.achartengine.org/ site. and that's why the gradle/maven method doesn't work (or the snapshot file was removed).
I succeeded using and adding it to my project by downloading the jar file from here:
https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip

How do I use another library in my app?

The title is a little misleading but I honestly don't know how to word it in any other way. This is my project structure:
I want to use the highlighted (fasteranimationscontainer-master) in my current app that I'm working on. I imported it by putting the jar file in my library folder then adding it to my library through Android Studio. But I try to create an object of that imported library, it doesn't show up/import.
I'm still learning how to use android studio so any help would be much appreciated!
1. Library with only the Source Code
To include a library with only the source code (like FasterAnimationsContainer) to your project, you only need to import it as a module from File -> New-> Import Module in Android Studio:
There should be a dialog for the project folder, enter the path where your library reside.
Then you need to add the module to your app build.gradle as a dependency:
android {
...
dependencies {
...
compile project(':fasteranimationscontainer')
...
}
}
Now you can use it in your project.
2. Library from Maven or JCenter
To add dependencies to your project where the library has uploaded to maven or jcenter, you need to modify your app build.gradle file and add extra lines configuring the packages you require. For example, for certain Google or Android, dependencies look like:
android {
...
dependencies {
// Google Play Services
compile 'com.google.android.gms:play-services:6.5.+'
// Support Libraries
compile 'com.android.support:support-v4:22.2.1'
}
}
Try to always read the library README first.
Suggestion:
If you still learning using Android Studio, you can read Using Android Studio. Then read Getting Started with Gradle, because Android Studio is tightly related with Gradle.

How to import github library in eclipse

I am trying to use material designing library https://github.com/drakeet/MaterialDialog from github in my eclipse but I didnt found any jar file in this library project. So how can I use this library in my project in eclipse
If you have a Gradle build, as mentioned in the README, you just add:
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}
As explained in the blog post, this looks like (in Android Studio)
You have to convert this library project from gradle to eclipse. You can get many links over the web for it. Try this.
The library project you are looking is build into android studio(Gradle). So I recommend you to use android studio instead of eclipse.
I recommend you to use Android Studio with Gradle support by default. But if you want use Eclipse download Gradle plugin and add this lib as dependency
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}

Gradle project Sync failed , How to fix?

I imported a material Dialog library from Github.
https://github.com/drakeet/MaterialDialog
And I imported the library in Android Studio.
However, now The Android Studio says "Gradle project sync failed, basic functionality (editing, debugging) will not work properly.
I tried alternative answers to similar problems from other questions here,
Gradle project sync failed?
Android Studio Gradle project sync failed
But, none works for me .
The error I get in console is : Error:Dependency ZyiaAlarm:materialDialog:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: F:\ZyiaAlarm\materialDialog\build\outputs\apk\materialDialog-release-unsigned.apk
My doubt is: Any way to restore the things back, I mean to get the gradle as it was as I am a beginner, there's much to learn about gradle.
OR
anyway to fix this library I imported ?
Any help will be appreciated!
Too long for a comment.
It is not clear how do you import it.
If you would like to build locally this library, you should have this type of structure:
root
MaterialLib
build.gradle
app
build.gradle
build.gradle
settings.gradle
where MaterialLib is the folder MaterialDialog/library from github.
You haven't to import the other folders from github.
Also in
app/build.gradle you should have:
dependencies {
compile project(':MaterialLib')
}
and in the settings.gradle you should have:
include ':app',':MaterialLib'
However I suggest you avoiding the local library.
Remove the MaterialLib (don't import code from github).
Just add to your app/build.gradle these lines:
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}
In this you should have this type of structure:
root
app
build.gradle
build.gradle
settings.gradle
and in the settings.gradle you should have:
include ':app'

How to add Android Support Repository to Android Studio?

I'm using Android Studio with an external Android SDK. I have installed the support library and the support repository. The support repository is in:
~/Development/Tools/android/sdk/extras/android/m2repository
When I add a dependency to the support library in the build.gradle file, like:
...
repositories {
mavenCentral()
}
...
dependencies {
compile "com.android.support:support-v4:18.0.+"
}
Android Studio cannot find the support libraries (cannot resolve symbol etc) and Gradle also cannot find the libraries:
Gradle: A problem occurred configuring project ':TestAndroidStudio'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':TestAndroidStudio:_DebugCompile'.
> Could not find any version that matches com.android.support:support-v4:18.0.+.
Required by:
TestAndroidStudio:TestAndroidStudio:unspecified
How do I specify in Android Studio and/or the build.gradle file the location of the Android support repository?
You are probably hit by this bug which prevents the Android Gradle Plugin from automatically adding the "Android Support Repository" to the list of Gradle repositories. The work-around, as mentioned in the bug report, is to explicitly add the m2repository directory as a local Maven directory in the top-level build.gradle file as follows:
allprojects {
repositories {
// Work around https://code.google.com/p/android/issues/detail?id=69270.
def androidHome = System.getenv("ANDROID_HOME")
maven {
url "$androidHome/extras/android/m2repository/"
}
}
}
Gradle can work with the 18.0.+ notation, it however now depends on the new support repository which is now bundled with the SDK.
Open the SDK manager and immediately under Extras the first option is "Android Support Repository" and install it
Found a solution.
1) Go to where your SDK is located that android studio/eclipse is using.
If you are using Android studio, go to extras\android\m2repository\com\android\support\.
If you are using eclipse, go to \extras\android\support\
2) See what folders you have, for me I had gridlayout-v7, support-v4 and support-v13.
3) click into support-v4 and see what number the following folder is, mine was named 13.0
Since you are using "com.android.support:support-v4:18.0.+", change this to reflect what version you have, for example I have support-v4 so first part v4 stays the same. Since the next path is 13.0, change your 18.0 to:
"com.android.support:support-v4:13.0.+"
This worked for me, hope it helps!
Update:
I noticed I had android studio set up with the wrong SDK which is why originally had difficulty updating! The path should be C:\Users\Username\AppData\Local\Android\android-sdk\extras\
Also note, if your SDK is up to date, the code will be:
"com.android.support:support-v4:19.0.+"
Android Studio 3
Make sure you have the latest version of Android Studio. The support library is included by default when you create new projects. If you are adding the Support Library to a project that doesn't have it, then you just need to add a single line to your app module's build.gradle file, and then sync gradle.
build.gradle
dependencies {
...
implementation 'com.android.support:appcompat-v7:27.1.1'
}
It should just be that easy, though there may be some things to note:
Android Studio should give you a warning nowadays if the support library needs to be updated. Just update the 27.1.1 numbers that I have here to whatever it tells you to. You can also manually check what the latest revision is if you want to.
The implementation keyword replaces compile that was used in Android Studio 2.x. (What's the difference?)
There are other support library packages that you may need to include depending on what your app uses (like constraint-layout or recyclerview).
Make sure that you have the latest updates for everything in the SDK Manager. Go to Tools > SDK Manager.
Documentation
Support Library
Support Library Setup
Support Library Features
I used to get similar issues. Even after installing the support repository, the build used to fail.
Basically the issues is due to the way the version number of the jar files are specified in the gradle files are specified properly.
For example, in my case i had set it as "compile 'com.android.support:support-v4:21.0.3+'"
On removing "+" the build was sucessful!!
Instead of doing this:
compile "com.android.support:support-v4:18.0.+"
Do this:
compile 'com.android.support:support-v4:18.0.+'
Worked for me

Categories

Resources