I am running react-native on windows 10 and I'm having a bunch of issues.
Firstly, at the root directory of the project, when I run
react-native run-android
I get this error:
JS server already running. Building and installing the app on the
device (cd android && gradlew.bat installDebug... 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/android-setup.html
And running it with --stacktrace --info did not help.
I then decided to manually do what the run-android script seems to be trying to achieve by going into the android directory and build my self by running
cd android && gradlew.bat installDebug
That, produced a bunch of result but still ended in error.
:app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not
incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Users\jiangyaokai\workspace\maincourse\android\app\src\main\java\com\maincourse\MainApplication.java:30:
error: cannot find symbol
new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey),
this, BuildConfig.DEBUG),
^ symbol: variable strings location: class R
C:\Users\jiangyaokai\workspace\maincourse\android\app\src\main\java\com\maincourse\MainApplication.java:30:
error: cannot find symbol
new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey),
this, BuildConfig.DEBUG),
^ symbol: method getResources()
2 errors :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: 8.109 secs
I wonder what I am doing wrong? Thanks.
Here's a snippet from your error message:
MainApplication.java:30: error: cannot find symbol new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey), this, BuildConfig.DEBUG), ^ symbol: method getResources()
it looks like it has something to do with CodePush plugin that you are using.
Could you follow the setup instruction here: https://github.com/Microsoft/react-native-code-push#android-setup and try again.
Solved.
symbol: variable strings location: class R
this is caused by the fact that R only has string but not strings, not sure why the code (auto generated) refers to strings.
symbol: method getResources()
This is missing because "this" refers to the inner class, wheres getResources() is only found in the outer class.
Overall, basically the code was wrong and correctly could not be compiled.
Thanks to all.
Related
I'm not sure what I've changed, but I can no longer get my app running on android devices. Running npx react-native run-android --deviceId abcdefg123 results in the following errors:
info Done writing bundle output
info Done writing sourcemap output
info Copying 47 asset files
info Done copying assets
> Task :react-native-reanimated:androidJavadoc FAILED
/Users/[....]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:5: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.Arguments;
^
/Users/[....]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:6: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.Callback;
^
/Users/[....]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:7: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.GuardedRunnable;
^
/Users/[....]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:8: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
...plus loads more similar errors, then...
100 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-reanimated:androidJavadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/Users/[....]/node_modules/react-native-reanimated/android/build/tmp/androidJavadoc/javadoc.options'
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 33s
2342 actionable tasks: 6 executed, 2336 up-to-date
error Failed to build the app. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew build -x lint
at makeError (/Users/[....]/node_modules/execa/index.js:174:9)
error Command failed with exit code 1.
I've been going in circles for a day now, trying to figure it out but I keep coming back to this error. Any ideas what I've done wrong, or what to try next?
Update:
If I remove the --deviceId flag, the app will run on the android emulator just fine. And it also works if I plug in a Samsung device I have.
When I plug in another device (Mi Max 2), I'm now getting a different error - see this post
However, the react-native-reanimated:androidJavadoc error described above still persists for both devices when I attempt to target either of them directly with the deviceId flag.
I was able to solve this issue, by following the installation guide of React-native-reanimated.
First install :
yarn add react-native-reanimated#next
Turn on Hermes engine by editing android/app/build.gradle :
project.ext.react = [
enableHermes: true // <- here | clean and rebuild if changing
]
Plug Reanimated in MainApplication.java
import com.facebook.react.bridge.JSIModulePackage; // <- add
import com.swmansion.reanimated.ReanimatedJSIModulePackage; // <- add
...
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...
#Override
protected String getJSMainModuleName() {
return "index";
}
#Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage(); // <- add
}
};
...
Then clean your project and Build using ./gradlew clean and ./gradlew build in android folder of your project.
https://docs.swmansion.com/react-native-reanimated/docs/installation
I've installed Flutter without Android Studio following these two tutorials: https://medium.com/#quicky316/install-flutter-sdk-on-windows-without-android-studio-102fdf567ce4 and https://dev.to/ejgamer21/install-flutter-without-android-studio-58bi.
I have connected my phone with USB debugging enabled and I've run flutter doctor: everything seems to be fine (although I haven't configured an IDE yet). Then I've tried to run the "Hello world" example that comes with Flutter using flutter run in the hello_world directory, but I get this error:
lib/main.dart:5:8: Error: Error when reading '/C:/b/s/w/ir/k/archive/flutter/packages/flutter/lib/widgets.dart': Impossibile trovare il percorso specificato.
import 'package:flutter/widgets.dart';
^
lib/main.dart:12:16: Error: Method not found: 'Key'.
key: Key('title'),
^^^
lib/main.dart:13:26: Error: Getter not found: 'TextDirection'.
textDirection: TextDirection.ltr
^^^^^^^^^^^^^
lib/main.dart:11:9: Error: Method not found: 'Text'.
Text('Hello, world!',
^^^^
lib/main.dart:9:11: Error: Method not found: 'Center'.
const Center(
^^^^^^
lib/main.dart:8:3: Error: Method not found: 'runApp'.
runApp(
^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\mpepi\Android\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\mpepi\Android\flutter\bin\flutter.bat'' finished with non-zero exit value 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 4,7s
Exception: Gradle task assembleDebug failed with exit code 1
("Impossibile trovare il percorso specificato" means "Couldn't find the specified path")
Something seems to be wrong with the path for the packages, I have located the required file at C:\Users\mpepi\Android\flutter\packages\flutter\lib which of course is different from the one in the first line. I have set all environment variables as the tutorials explain, what am I missing?
Delete in the .vscode file. Restart the flutter application of visual studio code and run 'Flutter run'. It worked for me.
You could try to set "File Transfer" mode on your phone, it usually is on the notification bar if the phone is conected
For some cases I've also faced the similar issue. This problem is likely to arise when flutter doesn't get the packages. It wasn't even getting the material package, like your widget package.
Fix: Go to pubspec.yaml file. Make sure your internet connection is on and working. If you're developing in vscode you'll find buttons at top-right corner. Click Get Packages and wait until flutter downloads the packages.
If you don't find those buttons, then from the command line navigate to the project folder and run flutter pub get or flutter packages get.
So I'm getting an error (at the bottom) that's most likely caused by me trying uninstalling react-native-pathjs-charts. The problem below only exists on android and not on ios.
Error:
/Users/a.lau/Projects/react-native/First_App/android/app/src/main/java/com/first_app/MainApplication.java:7: error: cannot find symbol
import com.horcrux.svg.RNSvgPackage;
^
symbol: class RNSvgPackage
location: package com.horcrux.svg
/Users/a.lau/Projects/react-native/First_App/android/app/src/main/java/com/first_app/MainApplication.java:29: error: cannot find symbol
new RNSvgPackage()
^
symbol: class RNSvgPackage
2 errors
: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: 5.997 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/android-setup.html
Also have in mind that the package was changed from:
import com.horcrux.svg.RNSvgPackage;
to
import com.horcrux.svg.SvgPackage;
so you have to change from new RNSvgPackage() to new SvgPackage()
hope it helps!
I guess you did not unlink before uninstalling the module. Install again, unlink and then uninstall the module.
npm install react-native-pathjs-charts --save
react-native unlink react-native-svg
npm remove react-native-pathjs-charts --save
Run with yarn add package_name is helped me.
I'm developing the cordova application, in which I want to have some kind of booking functionality through calendar. So for that, I installed very famous EddyVerbruggen/Calendar-PhoneGap-Plugin plugin.
But while building the project, it's throwing following error
/home/admin/Desktop/myApp/platforms/android/src/nl/xservices/plugins/Calendar.java:148: error: cannot find symbol
if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this.cordova.getActivity(), type)) {
^
symbol: method checkSelfPermission(Activity,String)
location: class ContextCompat
/home/admin/Desktop/myApp/platforms/android/src/nl/xservices/plugins/Calendar.java:157: error: cannot find symbol
ActivityCompat.requestPermissions(
^
symbol: method requestPermissions(Activity,String[],int)
location: class ActivityCompat
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':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: 43.228 secs
Error: Error code 1 for command: /home/admin/Desktop/myApp/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/admin/Desktop/myApp/platforms/android/build.gradle,-PcdvBuildArch=x86,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
I also gone through following threads..but still no help
Android M (6) compatibility
Issue related to the new Cordova version CLI >5
My Environment
Cordova-CLI : 6.1.1
Android-Sdk : 23
So, what should I do to resolve this issue?
I had the same problem after updating my plugins. To save time, I just used an older version of the plugin.
ionic plugin add cordova-plugin-calendar#4.4.4
I am using windows 8 as operating system.
I have a test method in Robolectric which has € in method name. When I run the test using Gradle wrapper in Android studio with gradlew test command,
it is showing me following error:
error: illegal character: \172
public void change_Ôé¼10() {
^
2 errors
:client:compileTestDebugJava FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':client:compileTestDebugJava'.
> Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
BUILD FAILED
I have researched about it and found out it could be related to encoding to UTF-8
It seems I need to use it without BOM:
Illegal Character when trying to compile java code
Android Project Compiled with Ant doesn't compile, Illegal Character Error
But I do not know how to fix it in a proper way exactly. Do you have any suggestion to fix in Android studio terminal?
Addenda: A friend of mine who uses Linux has no problem to run the test.
The proper way to fix this would be to remove the character from the method name.
I dont know of any actual limitations - you mentioned it works on a Linux machine - but it is terrible practice. Just spell out the word
Euro