Java class file not compiling or running on Android Studio - java

Where I try to run code in Android studio, its not working and displaying error attached below. example:
package com.example.jerry;
public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Got error when running Java class Test.class. This is the error displaying:
5:06:58 PM: Executing task 'Test.main()'...
Executing tasks: [Test.main()] in project G:\JavaProject\Jerry
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\Shakil\AppData\Local\Temp\Test_main__1.gradle' line: 21
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:Test.main()'.
> SourceSet with name 'main' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 271ms
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
5:06:58 PM: Task execution finished 'Test.main()'.

Related

react native Execution failed for task ':react-native-community_checkbox:generateDebugRFile'

hi everyone today I tried run the android
hello, today I got an error when I tried to run the android of the project I've been developing for 3 months.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
What went wrong:
Execution failed for task ':react-native-community_checkbox:generateDebugRFile'.
Could not resolve all files for configuration ':react-native-community_checkbox:debugCompileClasspath'.
Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-debug.aar
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
What went wrong:
java.lang.StackOverflowError (no error message)
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================
Get more help at https://help.gradle.org
BUILD FAILED in 4s
at makeError (/Users/arslantek/Desktop/TTDeneme23Ocak/TTMedMobil/node_modules/execa/index.js:174:9)
at /Users/arslantek/Desktop/TTDeneme23Ocak/TTMedMobil/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/Users/arslantek/Desktop/TTDeneme23Ocak/TTMedMobil/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/arslantek/Desktop/TTDeneme23Ocak/TTMedMobil/node_modules/#react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
how can i fix that?
BTW I fixed this problem by doing that
Replace this in android/build.gradle file
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ... your repository definitions
}
}
I refered that link https://github.com/facebook/react-native/issues/35210

I'm trying to build a Nativescript (angular) app and ran tns run android but unfortunately, I keep getting this build error

Full error:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\romario\git\trials\meo\platforms\tempPlugin\core\build.gradle' line: 6
What went wrong:
A problem occurred evaluating root project 'core'.
Failed to apply plugin 'com.android.internal.library'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Failed to build plugin #nativescript/core :
Error: Command gradlew.bat failed with exit code 1
notes
I am running java 11

Ionic Builed Project Failed : Could not determine the dependencies of task ':app:lintVitalRelease'

I'm new with ionic frameworks. i'm try to to build android with command sudo build --release android and get error as below
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.appcompat:appcompat:1.0.0, androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.vectordrawable:vectordrawable-animated:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.vectordrawable:vectordrawable:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Command failed with exit code 1: /Users/Muhamadkhairuldin/Google Drive/SifuApps/Apps/usahaone5/platforms/android/gradlew cdvBuildRelease -b /Users/Muhamadkhairuldin/Google Drive/SifuApps/Apps/usahaone5/platforms/android/build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
can anybody help me how to solve this?

Gradle project sync failed with a AccessDeniedException

I have been encountering this issue whenever I start up Android Studio. I would get a notification stating 'Gradle project sync failed'. The error code is as follows:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/####/AndroidStudioProjects/TEST/app/build.gradle'
line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> java.nio.file.AccessDeniedException: /Users/####/.android/build-ca
che.lock
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output. Run with --scan to get full
insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 0s
/Users/####/.android/build-cache.lock
I tried several solutions but none solved the issue. Any suggestions?

Android Studio app: Failure to Assemble APK after updating studio

I updated my Android Studio to 3.1 and then I changed the package name of my app from "jake.stackitupreimported" to "basic.games". Once that was completed, I clicked "gradle" to the right >>root>>tasks>>build>>assemble; then I got this failure notification below. Can anyone tell me how to fix this so I can assemble my app? Thanks!!!
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not find com.android.tools.lint:lint-gradle:26.1.1.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Categories