Gradle project Sync failed , How to fix? - android

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'

Related

Android: Importing a library module is causing compilation errors in my project using Gradle Plugin 3.1.2

I've been trying to figure this out for hours now. I simply want to import my library project into my project by reference. Importing a copy is not an option.
My settings.gradle looks like this
include ':app'
include ':FunLib'
project(':FunLib').projectDir = new File(rootProject.projectDir,'../FunLib/library')
My project's build.gradle
implementation project(':FunLib')
I wish I could point to the parent directory 'FunLib', but that simply doesn't work. So I have to point to the module which is 'library'.
Because my library's root build.gradle is outside of the 'library' directory, my plugins aren't getting recognized because I set my repo urls theres. I don't even know if it's using the right gradle version. I tried copying everything from my library root build.gradle to my project root build.gradle. Nothing has worked. Any project code that references code in my library is a compilation error. What am I missing here?
I finally realized that you don't really import a project. You import a module.

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 to manually import a gradle dependency in android studio

I'm trying to contribute to an open source project from Mapzen called "On the Road". (Github link)
I would like to edit and add some code to the project. At the moment I'm including the project using gradle with the following dependency:
compile 'com.mapzen:on-the-road:1.1.1'
Someone gave me a tutorial on how to do this here, but I'm getting a gradle error;
Error:Configuration with name 'default' not found.
What I did was clone the project from github, copied the entire master folder into my apps main and renamed it to "customLibrary".
I then added include':customLibrary' to my settings.gradle and compile project(':customLibrary') to my build.gradle(Module:app) file.
How do I import this project without the errors?
As you cloned the entire master folder, inside the customLibrary there is the build.gradle file which is the top-level file of the library.
You can't do it.
Since you are including the customLibrary folder, gradle is looking for a module build.gradle.
You have to clone the library folder instead of the entire master folder.
Otherwise you can use include':customLibrary:library' only to add the module library of the entire project.

Dependency error when using aar library

I have a module with a .aar file in libs folder. I used the solution posted here
[1]: http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/ to add the .aar file as dependency and was able to compile the module properly.
Now I want to use this module as a dependency to the main module in my project and compile. However when i try to compile, i do see an error which says that gradle was not able to find the particular .aar file. why would my main module not find a file which is in the libs folder of my sub module. Was wondering if anyone came across this issue.
my project structure is like this
--mainmodule
--build.gradle (submodule as a dependency)
--submodule
--libs
-- abc.aar
Here is the error gradle throws: When unzipping library ':abc:, either group, name or version is empty
If I understand your problem right and you've followed the steps described in the link you shared, then adding this to your mainmodule's build.gradle should do the job:
flatDir {
dirs "../submodule/libs"
}
You basically have the same issue that you fixed in your submodule, since the mainmodule is struggling to resolve transitive dependencies (abc.aar) of submodule.
Recommended way:
While the answer above should fix your issue, Android Studio supports a better way to do this. Import a local aar file via the File>New>New Module>Import .JAR/.AAR Package option in Android Studio v1.3+.
You can then have your submodule depend on that aar-module as follows:
dependencies {
compile project(':aar-module')
}

Imported module in Android Studio can't find imported class

I recently downloaded the ViewPagerIndicator library and imported it into android studio. After adding it to my project I get a rendering error "The following classes could not be found:" and points to com.viewpagerindicator.IconPageIndicator.
The steps I took were Files->Import Module->'library name', Project Structure -> Dependencies -> + the imported module. Then to my layout xml file I added the <com.viewpagerindicator.IconPageIndicator />, after that I got the missing class problem.
It compiles just fine and I went through all of the build.gradle and settings.gradle files and compared them to what they should be online.
MyApp->build.gradle has compile project(':library') under dependencies
settings.gradle has include ':library' with no build errors.
First of all, you must import your library project by following that path:
File --> New --> Import Module
After you have imported the library project successfully, you must check your build.gradle file inside your project's folder if the following line is present at the "dependencies" section:
implementation project(':NameOfTheLibProject')
Then your project must be built successfully.
I found that my issue was the Android Plugin Version under Project Structure --> Project was different to the version my plugins all used. Once I aligned them to the same version, I could see all my classes from my imported module.
Took me hours :(
I had the same problem. I just did: Invalidate / Restart ..
I too had trouble importing module as it was not appearing in list of modules. And way it worked for me is manually entering it in settings.gradle this way:
include ':app', 'module_name'
And in build.gradle
compile project(':module_name')
In my case, I did add in app gradle:
// Nearly deprecated.
compile project(':NameOfTheLibProject')
// Or
implementation project(':NameOfTheLibProject')
but it only works when I change
compileSdkVersion
minSdkVersion
targetSdkVersion
in app and the other modules are the same.
The following solution worked for me,just two steps.
Go to your project structure on android studio, select project from left side.Change Android plugin version to Gradle version press ok.
If error occurs after synchronization again go to project structure and select project.undo the android plugin version like before.Gradle will align the library and make the class visible to XML files.
The issue in my case was different compile and target SDK version,
mentioned in my main app module and your added lib module.
Once I matched both of them it worked perfectly.
So just open build.gradle file of app-level and lib module-level check for the SDK version.
settings.gradle
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(':wheel') // "Wheel" - you're project path name
}
In case you just changed the name of your project in the pubspec.yaml File, make sure to change the import names as well, because they will stay the same and therefore wont find the new named directory.
Ex. change this to :
import 'package:previousName/backend/connector/userConnector.dart';
to this:
import 'package:newName/backend/connector/userConnector.dart';
As far as i know, there is no terminal command for that, only find-in-files-replace :(

Categories

Resources