I've got a fresh React Native app, where I'm trying to use react-native-config:
npx react-native init RNConfigDemo
cd RNConfigDemo
yarn add react-native-config
echo "SOME_VAR="something"" > .env
I tried to add a line in my ./android/app/src/main/java/com/rnconfigdemo/MainActivity.java:
...
return BuildConfig.SOME_VAR;
...
and I always get the following:
RNConfigDemo/android/app/src/main/java/com/rnconfigdemo/MainActivity.java:40: error: cannot find symbol
return BuildConfig.SOME_VAR;
^
symbol: variable SOME_VAR
location: class BuildConfig
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILURE: Build failed with an exception
I can access non-.env defined BuildConfig, such as BuildConfig.DEBUG, with no issues. But my defined BuildConfig properties throw the above
I've tried running npx react-native link react-native-config, despite this having been autolinked, as well as the troubleshooting guidelines.
I verified the manually linked additions were present in their respective files.
I tried adding import com.facebook.react.BuildConfig, and then import com.rnconfigdemo.BuildConfig, to no avail.
I've followed all the steps for the Android build in the package's README
What's the issue here?
Related
I'm building a react native app that uses the react-native-vision-camera by Mrousavy (https://github.com/mrousavy/react-native-vision-camera) and I'm trying to create a frame processor plugin, following this guide https://mrousavy.com/react-native-vision-camera/docs/guides/frame-processors-plugins-android, which is basically a piece of native code, in this case Kotlin, that process the camera stream, frame by frame.
However, I've tried it several times and I keep getting this error related to Kotlin/Java code:
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
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
/home/luciano/wildsense/nam-vital-signs/rn/RNCamera0/android/app/src/main/java/com/rncamera0/MainApplication.java:16: error: cannot find symbol
import com.rncamera0.BasicFrameProcessorPluginPackage;
^
symbol: class BasicFrameProcessorPluginPackage
location: package com.rncamera0
/home/luciano/wildsense/nam-vital-signs/rn/RNCamera0/android/app/src/main/java/com/rncamera0/MainApplication.java:33: error: cannot find symbol
packages.add(new BasicFrameProcessorPluginPackage());
^
symbol: class BasicFrameProcessorPluginPackage
Note: /home/luciano/wildsense/nam-vital-signs/rn/RNCamera0/android/app/src/debug/java/com/rncamera0/ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
As far as I understand, there's a problem with how I'm importing and using the class BasicFrameProcessorPluginPackage but nothing of what I've tried fix it.
The file that contains the error (MainApplication.java), and the two files for the code I want to add (BasicFrameProcessorPlugin.kt and BasicFrameProcessorPluginPackage.kt) are in the same directory(.../android/app/src/main/java/com/rncamera0), and all of them have package com.rncamera0 as the first line.
Being that said, I will appreciate any help to find the solution to the error.
I cannot build after updating flutter and andriodX. I keep gettng the error below with a lots of warning messages. I upgraged flutter. I also executed flutter doctor. It has not helped.
The app was working fine and in order to user Firebase authentication,I created SHA1. After that it stopped working. Please suggest. I have looked over all other similar questions but I can't seem to find a solution.
Note: C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_core_web-0.1.1+2\android\src\main\java\io\flutter\plugins\firebase_core_web\FirebaseCoreWebPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.7+3\android\src\main\java\io\flutter\plugins\sharedpreferences\SharedPreferencesPlugin.java:18: warning: [deprecation] Registrar in PluginRegistry has been deprecated
public static void registerWith(PluginRegistry.Registrar registrar) { ^
1 warning
C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\webview_flutter-2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:31: error: cannot find symbol
private ThreadedInputConnectionProxyAdapterView proxyAdapterView;
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\webview_flutter-2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:112: error: cannot find symbol
new ThreadedInputConnectionProxyAdapterView(
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webview_flutter:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
BUILD FAILED in 2m 22s
Exception: Gradle task assembleDebug failed with exit code 1
gradle.properties
android.useAndroidX=true
android.enableJetifier=true
First of all, here is a test repo to replicate my issue
Hello there,
I'm trying to create a simple Android module for React-Native and I'm having some trouble getting the current Activity from the Java code.
This is not the first native module I worked on, but I never had to obtain an Activity reference since today.
The interested module is a bridge to the Estimote SDK, but this is not relevant to the issue.
The module in Android studio works perfectly, but when I try to build it with react-native run android I get the following error:
:react-native-estimote-android:compileReleaseJavaWithJavac
/Users/matteo/dev/react-native-example/react-native-estimote-android/android/src/main/java/com/mmazzarolo/estimoteandroid/EstimoteAndroidModule.java:64: error: cannot find symbol
Activity currentActivity = this.getCurrentActivity();
^
symbol: method getCurrentActivity()
1 error
:react-native-estimote-android:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
From my understanding extending ReactContextBaseJavaModule should be enough to grant me the usage of this.getCurrentActivity() (and Android studio agrees with me).
This is what I already tried to do:
- Implementing ActivityEventListener: same cannot find symbol error when I try to import ActivityEventListener;
- android/.gradlew clean
- watchman watch-del-all && rm -rf node_modules/ && npm cache clean && npm prune && npm i
- Tried the same repo on two different computers...
Any hints?
Thank you in advance.
the issue was with the version of react-native in module 'react-native-estimote-android'
Just change compile 'com.facebook.react:react-native:0.12.+' to
compile 'com.facebook.react:react-native:+'
This will resolve the cannot find getCurrentActivity symbol.
getCurrentActivity method is not available in react-native 0.12 version. Thats why it was throwing error.
#ReactMethod
public void start(final Callback callback) {
Activity currentActivity = getCurrentActivity();
this.mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
#Override
public void onServiceReady() {
mBeaconManager.startRanging(region);
callback.invoke();
}
});
}
Remove this from start method, if you do this.getCurrentActivity() it will referr to EstimoteAndroidModule context not to the app ReactContextBaseJavaModule context
Running Unity 4.5.4f1 and Playscape SDK version 1.14, building for android target, I am getting an Error unknown during the apply patch process in Unity. When running the executed command in CMD, I get the following error:
Error: Could not find or load main class com.googlecode.dex2jar.tools.Dex2jarCmd
The command input I provide (taken from the SDK logger) is the following:
"C:\Program Files (x86)\Java\jdk1.8.0_51/bin/java.exe" -clas
spath Assets/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/asm-all-3.3.1.jar;A
ssets/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/commons-lite-1.15.jar;Asse
ts/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/dex-ir-1.12.jar;Assets/Plugin
s/Playscape/Editor/ThirdParty/dex2jar\lib/dex-reader-1.15.jar;Assets/Plugins/Pla
yscape/Editor/ThirdParty/dex2jar\lib/dex-tools-0.0.9.15.jar;Assets/Plugins/Plays
cape/Editor/ThirdParty/dex2jar\lib/dex-translator-0.0.9.15.jar;Assets/Plugins/Pl
ayscape/Editor/ThirdParty/dex2jar\lib/dx.jar;Assets/Plugins/Playscape/Editor/Thi
rdParty/dex2jar\lib/jar-rename-1.6.jar;Assets/Plugins/Playscape/Editor/ThirdPart
y/dex2jar\lib/asmin-p2.5.jar -Xms1024m -Xms1024m com.googlecode.dex2jar.tools.De
x2jarCmd -f -o "C:\Users\THREEG~1\AppData\Local\Temp\vbqpzsn0.9r6.jar" "C:\Users
\THREEG~1\AppData\Local\Temp\jhcbrbrz.ocm./classes.dex"
I have checked the folder structure inside the project and dex2jar seems to be present. We did not see this issue before updating.
How can I resolve this?
I found it myself. This is most likely due to a spelling error in AndroidApkCreator.cs, row 39, where "lib/asmin-p2.5.jar" instead should read "lib/jasmin-p2.5.jar", judging by the file name inside the lib folder. This does not seem to completely remove the issue, however, as the CMD prompt still throws the following Error:
Could not find or load main class com.googlecode.dex2jar.tools.Dex2JarCmd
I have done my Automation in java using Junit and push that code to bitbucket and integrated it with jenkins. But when i am starting build after creating job it start failling and throwing some error. i am not able get that why it is not taking class path and how i can set class path to avoid this issue
Here is error coming on console
[javac] C:\Program Files\Jenkins\workspace\ABC-first-job\tst\com\cb\abc\ABCTest.java:110: error: cannot find symbol
[javac] Assert.assertTrue(response.contains(ABCConstant.DATA_MESSAGE));
[javac] ^
[javac] symbol: variable Assert
[javac] location: class ABCTest
[javac] 47 errors
BUILD FAILED
C:\Program Files\Jenkins\workspace\ABC-first-job\build.xml:48: Compile failed; see the compiler error output for details.
Total time: 2 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Check if there was any recent jdk version updates for jdk used to build the code. If you have a slave node also check the jdk version on the same.