I have imported a project from GitHub into Android Studio, however there is not a gradlew nor gradle.bat file.
I read about how I could generate them from questions like this one, so I ran the following command in the terminal:
gradle wrapper
However, I was given an error:
'gradle' is not recognized as an internal or external command,
operable program or batch file.
Also, in Android Studio, I have set the following setting:
Build, Execution, Deployment > Build Tools > Gradle [For current project]
...
Project-level settings
[x] Use default gradle wrapper (recommended)
[ ] Use local gradle distribution...
...
So my question is, how can I resolve the error and generate the gradlew and gradle.bat files?
It seemed as though in my case, I had deleted gradle wrapper files (I was trying to edit my GitHub project by importing it to Android Studio, and I had deleted the original files that I uploaded. I accidentally put in .gitignore to not upload those files to GitHub so they weren't there when I imported the project). I found them in my recycle bin and restored them.
Related
I'm trying to create a react-native android app following react-native "Getting started" here but when I try to run it both through CLI and with Android studio it gives me this error:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: C:\Windows\System32\AwsomeProject\android\app\build\intermediates\res\merged\debug: error: directory does not exist.
I tried deleting the build folder, cleaning the project and re-running it but it doesn't work.
How can I solve this?
If I understand your situation right:
There is absolutely no issue in your Java and XML.
Your project built just fine before this.
You tried to remove the build cache.
In addition to above you should remove the .gradle directory as well.
Unfortunately, some react-native modules have their own build directory inside the node_modules/ directory, so it is possible that you didn't clear the build cache for them.
Of course, it's really hard to go into each module and remove the build cache manually each time, but fortunately, you can change this behavior by adding to build.gradle file something like below:
allprojects {
// ...
buildDir = "${rootProject.rootDir}/.build/${project.name}"
}
Note: This tells gradle to use the same build directory for all projects.
I prefer ".build" as build directory but you may want to change that to "build" in above.
I know this question has been asked before but I haven't been able to fix the issue. I am running Android Studio version 3.1.4. I am trying to run an app that I cloned from a Github repository. But even before I try to run it, I get this error:
my-app: sync failed
Cause: https://downloads.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip
How do I fix this error? Thanks in advance.
You can check and change the distribution url in the properties file $rootDir/gradle/wrapper/gradle-wrapper.properties. See property distributionUrl.
Value should be something as follows (update the gradle version depending on your Android Studio version)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I've encountered a similar error when I tried importing the Sunshine project from the Udacity Android development course. I fixed the issue by downloading the mentioned zip file and extracted it to the C:\Users\<username>\.gradle\native folder.
Then in Gradle settings, use local Gradle distribution and set the Gradle home path to the downloaded gradle folder.
Check this video for more information
You can fix it by the following steps: (currently using Android 3.6.3)
This worked for me.
Exit android studio then make the below changes.
Go to C:\Users\UserName.android and rename the build-cache folder to build-cache.bak.
Go to C:\Users\UserName.AndroidStudio3.6\system and rename these folders:
caches to caches.bak
compiler to compiler.bak
compile-server to compile-server.bak
conversion to conversion.bak
external_build_system to external_build_system.bak
frameworks to frameworks.bak
gradle to gradle.bak
resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again.
If the folder is not in the Android3.6 folder, move to the next step.
Find the Gradle version from the gradle-wrapper.properties file
Download the Gradle bin file from internet, then extract it.
File menu-->Settings-->Build & Tools-->Gradle-->Use Gradle from: From
drop down select a specified location and browse to the location
where you have saved the Gradle bin zip file. (Default settings is use from ;gradle-wrapper.properties' file)
4.File menu-->Invalidate caches and re-run
[Gradle properties file]
[Gradle settings]
I just recently upgraded to the newest version of Android Studio (0.1.1), but I also used Android Studio to relocate my project to my Dropbox folder. So, I'm not exactly sure which one is causing this problem. When I build or try to run my project I get this error:
Cannot start compilation: the output path is not specified for modules
"actionbarsherlock",
"EmPubLite-EmPubLite".
Specify the output path in Configure Project.
I can't find any reference to "Configure Project" and the Project Structure option under File no longer works in this release.
Solution for Android Studio version < 1.0 :
You just have to go to your Modules settings > Project and specify a "Project compiler output"
and make your modules inherit from project. (For that go to Modules > Paths > Inherit project.
Or you can specify your output for each module if you want.
In order to do so you just need to follow this steps:
Open Project structure (F4 on one of the modules in the project explorer)
Click on Project tab on the left
Define "Project compiler output:" as YOUR_PROJECT_PATH\out (or any folder you want)
Click on Modules tab on the left
Go over all your modules and verify that under the Paths tab the Compiler output is set to "Inherit project compile output path"
I ended up re-importing the project using Gradle and it's back to normal. Very weird issue.
this is a problem that I face in case I open my phonegap project with Android Studio and Webstorm.
They are IntelliJ-based project and I guess they are both writing the files in .idea
Reimporting the project is the solution.
got same error while using studio feature to import from GitHub repository.
I deleted the whole project and .. cloned it using git terminal and imported as new project ... studio prompted to add VCS root, accepted ....everything was fine afterwards. As #lordhong prompted.
I found this:
http://www.chrisdew.com/blog/2013/07/17/android-studio-nosuchmethoderror-lazystringarraylist/
it is realy help for me.
Thus, in my case, the problem was to have two libraries:
protobuf-2.4.1.jar
and new protobuf-2.5.0.jar
it resulted error:
APK path is not specified for module “Example-Example”
To correct this, rename file protobuf-2.4.1.jar to protobuf-2.4.1.jar.disabled
mv protobuf-2.4.1.jar protobuf-2.4.1.jar.disabled
How I finally managed to fix after hours!
File -> Project Structure -> Facets -> choose module's facet -> Packaging. Enter in APK Path absolute path to apk to be created: C:\workspace\MyCompany\MyProject\myProject.apk
Press ok and run your project
I'm having trouble building my project with Jenkins and referencing the Sherlock project library.
I can build the project with ant on my local system. The problem seems to be referencing the Sherlock library on the build server.
I pass an environment variable to ant with the relative path to the Sherlock library project:
android.library.reference.1=../../buildlibraries/androidlibraries/sherlock/library
I'm getting this error.
**BUILD FAILED**
/SDK/android-sdk-macosx/tools/ant/build.xml:595:
The following error occurred while executing this line:
/SDK/android-sdk-macosx/tools/ant/build.xml:571:
../../buildlibraries/androidlibraries/sherlock/library resolve to a path with
no project.properties file for project /Users/Jenkins/buildlibraries/androidlibraries/sherlock/library
I checked and a project.properties file does exist at that location.
It has these properties:
android.library=true
# Project target.
target=android-14
I had the same thing happen to me just now. I use both a Windows and Mac to develop with. I watne d to test my project on both platforms. It built just fine on my Windows machine, but broke on my Mac. When I looked at my project.properties in my Android application (not library projects) on the Mac, I saw that my library projects were referenced this way:
android.library.reference.1=LibraryProjects\\my_lib_project
I changed it to the line below, and it worked just fine!
android.library.reference.1=LibraryProjects/my_lib_project
I solved the issue by editing and checking in the project.properties file with the same property: android.library.reference.1=../../buildlibraries/androidlibraries/sherlock/library
I'm not sure why it works. Why would ant care if the property is passed in by Jenkins vs. declared in the project's property file?
Now I have two paths in my project.properties file: one for a local build and one for the build on Jenkins.
I had similar issue with error ../google-play-services_lib resolve to a path with no project.properties file for project. It has to work in Jenkins CI (Cloudbees), so no manual project.properties editing.
My solution was to replace android update lib-project --path ... with ugly but working echo "android.library.reference.1=../../../..$ANDROID_HOME/extras/google/google_play_services/libproject/google-play-services_lib" >> project.properties in Jenkins shell command.
I had this problem because I hadn't downloaded the google play services package using the android tool. When I checked my android sdk directory ($ANDROID_HOME) there was no "$ANDROID_HOME/extras/google" folder.
I fixed this by running android and downloading "Google Play services" found in the extras section.
I'm adding an android library project to my android app (in this case, Beintoo). It's not mine; It's an external library. However, it doesn't come with a build.xml. Building in Eclipse works fine, but when I attempt to build my app with ant, I get this:
BUILD FAILED
C:\Sandbox\MyProject\build.xml:110: The following error occurred while executing this line:
C:\Sandbox\MyProject\build.xml:41: The following error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:515: Invalid file: C:\Git\Beintoo-Android\beintoo-android-sdk\BeintooSDK\build.xml
It's perfectly true. The file is invalid, because it doesn't exist. I wouldn't know what to do to add it safely, nor if that's even a good idea.
I have learnt that I can't simply build the library project into a jar. How can I get my project to build in Ant with this library project?
Ok, so, Error 454's answer was close, but not quite right. Since r14 of Android Tools, every library project must have it's own build.xml if it is to be built by Ant, as noted here:
https://groups.google.com/forum/?fromgroups#!topic/adt-dev/Z2e3dY-3Ma0
Running android update lib-project (which, as Error 454 notes, is in the android-sdk/tools folder which should be in PATH) on the library project will add a generic build.xml, and allow the main project to build.
For library projects, you need to browse to the library project root and run:
android update lib-project -p .
The android executable is in the android sdk/tools folder which should be added to your path variable in your OS. Once you run this, the necessary build files will be generated and your ant build should succeed.
Similarly, if your root project doesn't have the necessary build files, you will need to browse to the main project root and run:
android update project -p .
Additionally to the two previous correct answers I had to add --target android-16 because I was getting an "Error: The project either has no target set or the target is invalid."
So in my case
android update lib-project -p . --target android-16
Did it. (replace the 16 as you need)