React-native: Andoid app showing error ":app:compileDebugJavaWithJavac FAILED "

Created on 15 Oct 2015  Â·  22Comments  Â·  Source: facebook/react-native

Hi, I seem to have followed all the steps given in your docs correctly. I also got the iOS app to work, but I'm getting this error whenever I try to run it in android.
"Sankhadeeps-MacBook-Air:native sankhadeeproy$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee061Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore061Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco061Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline061Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp061Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0120Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
/Users/sankhadeeproy/Sites/projects/native/android/app/src/main/java/com/native/MainActivity.java:1: error: expected
package com.native;
^
/Users/sankhadeeproy/Sites/projects/native/android/app/build/generated/source/r/debug/com/native/R.java:8: error: expected
package com.native;
^
/Users/sankhadeeproy/Sites/projects/native/android/app/build/generated/source/buildConfig/debug/com/native/BuildConfig.java:4: error: expected
package com.native;
^
3 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 27.348 secs
Could not install the app on the device, see the error above."
Any help would be appreciated.

Locked

Most helpful comment

You creating a new project and new name doesn't look like a real solution to this.

All 22 comments

Solved! A new project with a different name fixed it.

hi @sankhadeeproy007 did you just create a new project and copy over your files or what?
Thanks..

No, it happened with a new project. However I did create a new project and copied some files over later in another project.

It should be documented somewhere, you can't create a react-native project called native (I just had the same problem).

It just happened to me. I started a hello world project but ended up doing more there.. finally, wanted to move them over. Created a new project with RN init and copied my assets over. npm install installed all dependencies and react-native run-android fails with this error "app:compileDebugJavaWithJavac FAILED". Any workarounds apart from recreating the project with different name?

please help me to remove this error
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

I might be late but this may help to others also.yesterday I came across asame issue then I changed sdk versions in gradle file ,problem solved :)

You creating a new project and new name doesn't look like a real solution to this.

Seems there is a bug in android studio, i got the same error when i started a new project, in my case, it happens because i choose scrolling activity first by mistake, and then i go back with the previous button, choose empty activity with a name MainActivity. After i clicked the finish button, the stupid AS create an activity called MainActivity, but instead of activity_main.xml in layout folder, there was the content_scrolling.xml has been created.

no problem, thank to all for reply i have solved this issue last time.

On Tue, Jan 3, 2017 at 10:25 AM, Zain Zhu notifications@github.com wrote:

Seems there is a bug in android studio, i got the same error when i
started a new project, in my case, it happens because i choose scrolling
activity first by mistake, and then i go back with the previous button,
choose empty activity with a name MainActivity. After i clicked the finish
button, the stupid AS create an activity called MainActivity, but instead
of activity_main.xml in layout folder, there was the content_scrolling.xml
has been created.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/3437#issuecomment-270053738,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APlnXWAfEb0W14kO_s2qXYX7hWV47iKxks5rOdu_gaJpZM4GPQVL
.

--
zubizubi

If you have Android studio, then try open the android code, and run 'project' ==> 'clean', or just do cd android & ./gradlew clean, probably solve the issue.

cd android & ./gradlew clean solves it but it slows down every build. Isn't there a proper fix to this?

Please help me solve error With nativescript with JavaScript. When I tried to built project it gives this error. I tried some of above solutions. But nothing works for me.
Execution failed for task ':compileF0F1F2F3F4DebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

untitled

kindly please help me with this
untitled

Getting same issue

> Task :react-native-fbsdk:compileDebugJavaWithJavac FAILED /Users/.../node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppEventsLoggerModule.java:209: error: cannot find symbol @ReactMethod(isBlockingSynchronousMethod = true) ^ symbol: method isBlockingSynchronousMethod() location: @interface ReactMethod Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/hugohyz/code/hugoh1995/dogtime_react/DogtimeReactInit/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/Utility.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

please help me to remove this error
TRIED WITH 2 DIFFERENT PROJECTS BUT BOTH OF THEM GIVEN SAME OUTPUTS

1 error
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 24.051 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Also running into this. Had a project running successfully on another machine, cloned my repo to this machine, and as far as I can tell I have everything set up correctly but still getting this pop up. Running ./gradlew clean from the Android folder also doesn't seem to do anything.

I was getting same issue -> failed for task ':app:compileDebugJavaWithJavac'.

Updating react-native-fbsdk to 0.7.0 in package.json fixed it for me! :)

Try the this stack overflow answer Basically clear global .gradle cache

please help me !
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 23.054 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

I solved this issue by deleting the .gradle folder inside the android folder.

Was this page helpful?
0 / 5 - 0 ratings