I have application module, 4 android lib modules, and 2 java modules. I'm trying to add one more android lib module, but AS ignores it.
New module is created and added to settings.gradle. AS does not add *.iml file to module folder, and .idea/gradle.xml and ./idea/modules.xml files don't contain records about new module. I tried to generate *.iml file by myself, and added records to .idea/ files. It starts working, but then i got message
The modules below are not backed by Gradle anymore. Check those to be
removed from the ide project too
, and *.iml file was removed.
AS 2.2.3, gradle 2.14.1
UPD 1.
The problem was in unexpected place. I tried this solution, because it was very similiar to my problem, tried to delete module and add it again (with new name). But nothing helped. After opening Gradle tab (right top corner), I found that new module was highlighted with dark grey color, right-clicked on it, and saw that "Ignore Gradle project" was checked by default.
I unchecked this item, but after next gradle sync I got above message, and this item was checked again automatically. Also in event log
Unsupported Modules Detected: Compilation is not supported for following modules: modulename. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.
UPD 2.
Seems like https://code.google.com/p/android/issues/detail?id=77983 and https://code.google.com/p/android/issues/detail?id=230550
The solution that helped me:
Close AS
Remove all *.iml files
Remove .idea dir
Remove .gradle dir
Rename project
Open project with AS
android {
...
buildTypes {
...
dexOptions {
preDexLibraries true
}
}
}
Related
I am trying to rebuild an old (working) project in AndroidStudio. It builds Ok but strangely, the project's build.gradle is not visible in the AS Project tab.
Note that the module's build.gradle appears but not the project's build.gradle.
Both files ARE indeed there
Directory of C:\dev\AndroidProjects\apps\Passwords\app
11/09/2020 04:16 PM 767 build.gradle
1 File(s) 767 bytes
Directory of C:\dev\AndroidProjects\apps\Passwords
11/09/2020 03:13 PM 352 build.gradle
1 File(s) 352 bytes
The project otherwise builds just fine.
The projects build.gradle IS active: If I make changes to it outside AS using a text editor, the changes DO take effect.
What I've Tried:
Restart PC and AS
Cleaned/Rebuilt Project
Invalidate Caches & Restart
Searched SO for problem. Question 47406517 was similar but solution didn't work
Copy build.gradle from another known-good project.
Notes:
Android Studio: V3.6.3
PC: Win10-64
Project Name: "Passwords"
I'm at a loss for other things to try. Any suggestions?
(I guess as a work-around, I can always use an external text editor but that's annoying).
I found the answer in SO question #46230078. The solution was simple: Close AndroidStudio, delete the directory ".idea" from the project directory, restart AndroidStudio. This did it!
I have converted one of our Android projects from the old Groovy settings.gradle and build.gradle files to the new Kotlin DSL, i. e. settings.gradle.kts and build.gradle.kts.
While "it works on my machine" - in particular: the original project I converted from Groovy to Kotlin works fine in its original directory - all my co-workers are unable to open the project when they clone the repo. Importantly, neither can I open the project myself (with the same AS installation on the same machine) when I clone the repo to some other directory. So, I suspect there is some additional detail missing in some configuration file but I cannot seem to figure out which...
Details:
When I just use File > Open... and then select the project folder, I only get the error message "The project 'xxx' is not a Gradle-based project"
When I instead go through Import Project (Gradle, Eclipse ADT, etc.) and then select Import project from external model and Android Gradle Android Studio will create an empty build.gradle file and fail with the error message "ERROR: Plugin with id 'com.android.library' not found." Deleting the build.gradle just goes back to the error message I described in the first bullet point.
I am aware of this Github issue, which seems to describe the same problem, but it's been very quiet and I thought someone around here must have figured out a solution to this...
Oh, command line builds work everywhere - this is purely an Android Studio problem.
UPDATE: When I copy the whole project to a new folder (instead of cloning the repository) I can open it without any problems. So, am I correct in assuming that there must be something inside the folder - but not in Git - that makes it work?
I was able to 'fix' it by deleting the .idea directory and reopening the project. The .idea directory is usually not committed in git but I guess copying the directory invalidates the directory structures in the files within the .idea directory.
The whole bug is easily reproducible when you click on File > Re-import Gradle project.
#Boni2k answer does not work for me.
I have to rename the root build.gradle.kts back to build.gradle, fix the syntax error, sync the project (which works fine immediately), and rename the file back to build.gradle.kts. Then the error is gone and I can sync the project successfully.
What I did to raise the error was that I moved the project to a different folder, and rename the project.
I am using Android-Studio to build my app. In order to add libraries, I need to edit build.gradle file but I don't see it anywhere. Even if I changed files-view from android to project and vice-versa .
Why don't I see/have build.gradle ?
Check in your git repository if it contains the build.gradle files.
If not, you can just add manually to your project.
You should have something like this:
root
|--app
|----build.gradle
|--build.gradle
|--settings.gradle
You can also create a new blank project and copy the build.gradle files into your existing project (of course in the app/build.gradle file you have to change the values and the dependencies).
With huge help from #JuLes (commentting on my question) I figure out how to solve it. Here is what I did:
I totally removed Android-Studio following this guidance, then ...
I installed Gradle from this link, then ...
I re-installed Android-Studio following this link:
I am gussing the main problem was that I didn't installed Gradle manually and hence Android-Studio was using some sort of Gradle-Wrapper to allow the application to run.
Now, finally I can edit build.gradle.
BIG THANKS TO: JuLie
i'm trying to use existing project as a library in android studio, it was easy in eclipse. i've imported the project into android studio and every thing works fine but when i try to use is as a library its says "Error:Configuration with name 'default' not found."
i've included the the project in a directory named librairies and i'ave included in setting.gradle
include ':app'
include ':libraries:droidar1'
and i have changed the library into com.android.libray
and added the model in dependecy but its no use
This error means it's looking for a module at a given path, in this case two paths app and libraries/droidar1 and is not finding a buildable module at one or more of them. Make sure there is a build.gradle file at each of those paths with an apply plugin that will tell the build system what plugin to use to build the module.
I'm trying to use the Parse library in Android Studio. I have used the basic example on their website and added the jar to the libs folder as well as added as a global library. Nothing seems to be working without errors:
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: cannot find symbol variable Parse
Gradle: cannot find symbol variable ParseAnalytics
Gradle: cannot find symbol class ParseObject
Gradle: cannot find symbol class ParseObject
Android Studio gives no errors in the code.
I encountered the same problem too and here's what I did:
I placed the entire Parse-1.2.5 in the libs folder (I didn't have to create the folder as Parse's quickstart said).
Open the build.grade file. There are two of them - open the one that's at the same level as the src folder
You'll see two instances of "dependencies". Add the following to the "dependencies" that is NOT nested under "buildscript":
compile files('libs/Parse-1.2.5/Parse-1.2.5.jar')
If that still doesn't work, try right clicking the Parse-1.2.5.jar file and select "Add to Project Library"
Hope that helps!
As of version 1.10.0 the Parse SDK is open source and available on Maven, so now you can just put this in gradle:
compile 'com.parse:parse-android:1.10.0'
Just replace 1.10.0 with whatever the newest verison is at the time you read this.
Alternatively, if you like living on the edge, you can tell gradle to auto-update:
compile 'com.parse:parse-android:1.+'
EDIT: On 1/28/16 Facebook announced that they are retiring the Parse service, so if you are starting a new project I would urge you to consider using a different service.
The problem is that gradle doesnt do a proper rebuild and somehow still reads a cached version of the old build script. Add the libs as per above reply then open a terminal and do a gradle clean. If you are running on windows (or any platform for that matter) I suggest you do a quick internet search on "intellij clean" to see what it does and then simply do a manual clean by deleting the appropriate folder. This should do the trick!
edit: before manually deleting the appropriate folders/caches you can also first try clicking on file -> invalidate caches. If this still doesnt work manually delete all the appropriate folders and caches
1) I unzip the folder into the libs folder:
YourProject/app/libs/Parse-1.9.2/ <<< here all the jar files.
2) and then in the dependencies section from your build.gradle, I set:
dependencies {
...
// Parse 1.9.2
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs/Parse-1.9.2', include: 'Parse-*.jar')
...
}
I set the specific folder where the jars are contained dir: 'libs/Parse-1.9.2'
Hope it helps!
In your app gradle add below code
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
In AndroidManifest.xml file add below permission
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
In your Application class inside onCreate() method add below code
Parse.initialize(this, "application_id", "client_key");
ParseInstallation.getCurrentInstallation().saveInBackground();
then run. Hope this works, for more info https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing
Place the contents of the Parse-1.. folder in to your libs directory ... not the Parse-1.. folder itself. That worked for me.
donwload parse SDK for android and follow instruction given on below mentioned link:
https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing
Add the SDK to your app in Android Studio
Add the following to your build.gradle
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
and then
Add the following to your Application#onCreate():
Parse.initialize(new Parse.Configuration.Builder(myContext)
.applicationId("YOUR_APP_ID")
.server("http://YOUR_PARSE_SERVER:1337/parse")
...
.build()
);
Your app must request the INTERNET and ACCESS_NETWORK_STATE permissions, if it isn't doing so already. Add the following lines inside the tag in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Compile and run!
After installing the SDK, copy and paste this code into your app, for example in your Activity#onCreate():
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
You will also have to add an import statement at the top of your file:
import com.parse.ParseObject;
Run your app. A new object of class TestObject will be sent to the Parse Server and saved.
Unzip the Parse.zip file
Go to Android Studio. Change Android to Project (top left corner).
Expand the folders and find "libs".
Copy the "parse" folder and paste it in the "libs".
Now, under the "src" open build.gradle
Paste the following under dependencies-
compile files('libs/Parse-1.9.4/Parse-1.9.4.jar')
compile files('libs/Parse-1.9.4/bolts-android-1.2.0.jar')
(give your Parse version name)
Done. You gotta ready to go!!