There is this Project i am dealing with, you can check it's Git Repository here :
Arcore repo
The Project builds successfully and runs on emulator or physical device while using android Studio .
Problem: I cloned this project and opened it with vscode, and run ./gradlew clean build; this goes as expected!!
But it seems to always get stack at :
./gradlew run
with "error" run task is not found in the root project
Just add this code to your build.gradle file:
plugins {
id 'com.android.application'
}
The com.android.application plugin already includes the task run, so your error should be fixed.
For more information regarding this plugin, read the official documentation here (Android), and here.
For Future visitors of this thread, I will answer my Question here:
As a contribuer stated to implement com.android.application plugin to root build.gradle, this did not implement the application and run task within the root project. Instead the plugin needed simply was:
// root build.gradle
plugins {
id('application')
}
Now re-running ./gradlew build does add the run task, provided by the plugin above .
Related
When I try to build a kotlin program on android studio, it displays the notification:
*Unable to find Gradle tasks to build: [:].
Build mode: COMPILE_JAVA.
Tests: All.*
This happens when I try to debug or run a code like
fun main(){
println "hello world \n I am Michael Girum."
}
In Android studio, under the project source files, under android>app>src, right click on build.gradle, and click Run 'android'
This will than compile, you can than run the project.
I tried to build an old Android project
classpath 'com.android.tools.build:gradle:2.3.1'
and I solved it by adding a
settings.gradle
with content
include ":app"
From this post (Best way to add Gradle support to IntelliJ Project) I can see that what I need to do is "Add build.gradle in your project's root directory."
I was hoping someone could please explain how I do that in intelliJ? (been searching and reading - still baffled).
I understand a root directory the folder which is the parent for all the project sources, but in standard JavaFX project in intelliJ what is it/how do I find it/assign it, and then how do I add build.gradle?
Note: these steps assume that you are using the latest JDK version (17).
In the project browser, right click on the project name and create a file named build.gradle:
Write a build script. Here is a template for JavaFX applications:
plugins {
id "application" // Use Application plugin
id "org.openjfx.javafxplugin" version "0.0.9" // Use JavaFX plugin
}
mainClassName = "my.package.Application" // Set this to your main class
repositories {
mavenCentral()
}
javafx {
version = "16" // JavaFX Version
modules = [ "javafx.controls" ] // JavaFX modules. Add them to this array.
}
Once you have finished, import the project:
This may take a while depending on your internet speed.
You may have to adjust runtime configurations to use Gradle, but that shouldn't be necessary.
You may encounter the following error:
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
If that is the case, install Gradle CLI (if you haven't already), and open a command prompt/terminal in the project folder.
Run the following command (works on Windows/Mac/Linux):
gradle wrapper --gradle-version=7.3 --distribution-type=bin
Once you have done that, reload the Gradle project.
I could not resist another GIF:
You may also need to rearrange the source folders:
I apologise for the cat photo, but it was just a placeholder image. I definitely didn't specifically choose it.
While learning android studio from udacity they asked me to download a project; I did so but while I was importing it to android studio I got an error message:
The project uses Gradle 2.10 which is incompatible with Android Studio 2020.3.
Why did I get this error?
If you did not figure this out yet, I am just starting the same project too. I changed the classpath like above. I then found a website to use the latest version of gradle and the plugin. It says "You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or by editing the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file." I did the first one.
Then, I got errors for both build.gradle files in the project and app version. I get this error: Could not find com.android.tools.build:gradle:7.0.3
If you get this error, click the link "Add google Maven repository and sync project". Then you have to click "Do refactor".
Now you come across another error in one of the build.grade files. This stackoverflow link will tell you: Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]
Finally, replace testCompile with testImplementation and then you should get BUILD SUCCESSFUL.
The project's Gradle version you're trying to clone is outdated. Change it based on your android studio version.
on your build.gradle(Project) change the version and sync
classpath "com.android.tools.build:gradle:4.1.2"
Got the solution :)
In gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
In build.gradle project level:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
In build.gradle module level:
Replace all "compile" with "Implementation" and do other suggested version updated and you are done here :)
Hope this works for you, if yes just press that up button :)
If not getting any solution, the best you can do is copy the "app" folder of your project(using file explorer) and paste it in a newly created project(should be of same name as of your project), in that way you'll get already synced gradle and newly created version of your app.
Because, every important thing in your project is present in its app folder and when you create a new project with same name and copy app folder from your older version of your project, you will have a newer version of your project with all same resources.
Note: You can't move through branches and other commits
I saw this issue several times with Android studio. Below trick worked me the best.
Android Studio suggests to upgrade to newer version, please upgrade it and let it sync
Mostly you would see error message again
Now, Go to File -> Invalidate Caches/Restart
It should work now
If it shows same error then I don't know what to do.
If it shows different error then repeat from step 1 to 3 for new error.
Hope, it helps some..
My project was working and everything was fine but have no idea what happened suddenly that I'm getting error when I want to build my project. This is Gradle output:
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/values.xml:265: error: Resource entry com.crashlytics.android.build_id is already defined.
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/com_crashlytics_build_id.xml:9: Originally defined here.
Since both of these files are auto generated I cannot do anything :(
I tried to clean project by Build>"Clean project" but nothing happened.
I tried to clean project by ./gradlew clean assembleDebug but nothing happened.
I tried to invalidate cache of Android Studio by File>"Invalidate caches / Restart" but nothing happened.
I even restarted my f.laptop but still same problem displays when I build the project.
I have this classpath in my build script but as mentioned it was working...
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
Any suggestion would be appreciated. Thanks.
I have an app of two flavors: Debug and Release, with two manifests and two distinct packages com.myapp.release and com.myapp.debug for each flavor, respectively.
After migration from Fabric.io to Firebase Crashalytics, a Gradle warning
appeared about duplicate com_crashlytics_build_id.xml:
/home/.../app/build/generated/fabric/res/flavor1/debug/values/com_crashlytics_build_id.xml [string/com.crashlytics.android.build_id] /home/.../app/build/generated/crashlytics/res/flavor2/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources
Fix:
in build.gradle
remove
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
remove
apply plugin: 'io.fabric'
I had the same problem.
My mistake is I add fabric plugin and firebaseCrashlytics plugin on my gradle.
(reason : plugin build id duplicate crash)
You must fix select A and B plugin.
A : apply plugin: 'com.google.firebase.crashlytics
B : apply plugin: 'io.fabric
I had the same problem, one of my dependencies had mistakenly added the com.crashlytics.android.build_id via craslytics's auto genereted xml file.
It was a library project and deleting :
library/src/main/assets/crashlytics-build.properties
library/src/main/res/values/com_crashlytics_export_strings.xml
fixed it for me.
Fix different io.fabric.tools:gradle versions
Different io.fabric.tools:gradle versions in the app and library caused this for me.
I'd the following in the app's build.gradle:
classpath 'io.fabric.tools:gradle:1.19.2'
And the following in the library's build.gradle:
classpath 'io.fabric.tools:gradle:1+'
I changed both to following to fix it:
classpath 'io.fabric.tools:gradle:1.19.2'
PS: We need better error messages. As programmers we waste of lot of time when the error messages are not only bad, but as in this case, downright misleading.
remove this also besides fabric
crashlytics {
enableNdk true
}
I have recently updated my Android Studio from 0.2.9 to 0.3.1 and when I try to compile my project i get the error:
org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.7-bin.zip'.: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.7-bin.zip'.
I have tried to use the terminal and successfully cleaned and rebuilt by using gradlew clean and then gradlew build. I have even invalidated the caches by using File -> Invalidate Caches / Restart but I still can't build using Android Studio.
Do you have any ideas on why I have this problem and how can I fix it?
Edit #1 : When I go into Settings -> Gradle I get an error: "Gradle location is unknown". Is that the problem? Where should that path point to?
I have fixed the issue by using the advice from this post.
I have updated gradle-wrapper.properties from <AppNameProject>/gradle/wrapper/:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
to
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
and build.gradle from <AppNameProject>/<AppName>/:
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}