I have an ionic project, and for now the unique platform that i am built for is android, all features in project were working fine, previously when i export to APK this project, also works perfectly, the project in that time already had an android studio project linked in, but despite this everything worked fine.
Recently, looking in a page I saw that a project of ionic can be easily imported in android studio clicking on "Import project (Gradle, Eclipse, ADT, etc.)", so I clicked on that option and looked for my .gradle file.
Once I found it, I opened this in Android Studio, some message was displayed importing the project, something like "This version of gradle seems to be older, we recommend to update gradle, click here to update gradle", so i clicked in, but doesn't install successfully, for other errors...
As I didn't know what to do, I simply closed Android Studio, and tried to build APK once again but from the CMD, my APK was successfully built.
But now when I install the APK, run the APK and try to use the functionality of 2 plugins, one plugin simple doesn't works, but don't close me the application (imagePicker).
In case of the other plugin (googleMaps), when i try to change to the page where i using googleMaps, the app will simple got closed.
(I think was android studio gradle opened and attempted to upgrade and this break the plugins functionality).
Other thing that was changed is that previously when i run command:
ionic cordova build android -c
the output APK looks like:
app-debug.apk
now when i run this command the name is something like:
android-debug.apk
This thing means that I will never be able to run command:
ionic cordova run android
because the installation apk name that is recognized for the command is app-debug, not android-debug.
This is the output, but if i try to remove android platform and add it again, an error happens if y try to run:
ionic cordova build android -c
this is the output that i'm getting using android 6.4.0:
cordova-android-support-gradle-release: Android platform: V6
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\cordova-android-support-gradle-release\starter-cordova-android-support-gradle-release.gradle
cordova-android-support-gradle-release: Android platform: V6
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\cordova-android-support-gradle-release\starter-cordova-android-support-gradle-release.gradle
ANDROID_HOME=C:\Users\angela\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_221
Subproject Path: CordovaLib
Starting a Gradle Daemon (subsequent builds will be faster)
+-----------------------------------------------------------------
| cordova-android-support-gradle-release: 27.+
+-----------------------------------------------------------------
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
config.xml
../config.xml
../../config.xml
preference = 10
name = ScrollEnabled, value = false
name = android-minSdkVersion, value = 19
name = BackupWebStorage, value = none
name = SplashMaintainAspectRatio, value = true
name = FadeSplashScreenDuration, value = 300
name = SplashShowOnlyFirstTime, value = false
name = SplashScreen, value = screen
name = SplashScreenDelay, value = 3000
name = AndroidPersistentFileLocation, value = Compatibility
name = GOOGLE_MAPS_ANDROID_API_KEY, value = AIzaSyAP7l8T_EYdETsJfpwtotTE5iDCoMebJlY
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_1v9usha2n179nr38j15ea2rs.run(C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\build.gradle:146)
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:preBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:compileDebugRenderscript UP-TO-DATE
:checkDebugManifest UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:prepareLintJar UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:createDebugCompatibleScreenManifests UP-TO-DATE
:processDebugManifest UP-TO-DATE
:splitsDiscoveryTaskDebug UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:javaPreCompileDebug UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk NO-SOURCE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexBuilderForDebug UP-TO-DATE
:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes NO-SOURCE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE
BUILD SUCCESSFUL in 2m 50s
44 actionable tasks: 1 executed, 43 up-to-date
Built the following apk(s):
C:/xampp/htdocs/MyQuestApp/myquestapp/platforms/android/build/outputs/apk/debug/android-debug.apk
But this is the different output that i'm getting if i uninstall platform android and re-add it with:
ionic cordova platform add android
Output when i run ionic cordova build android:
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\app\build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\cordova-android-support-gradle-release\starter-cordova-android-support-gradle-release.gradle
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\app\build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\cordova-android-support-gradle-release\starter-cordova-android-support-gradle-release.gradle
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\angela\AppData\Local\Android\Sdk (DEPRECATED)
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :wrapper
BUILD SUCCESSFUL in 1m 23s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :app
+-----------------------------------------------------------------
| cordova-android-support-gradle-release: 27.+
+-----------------------------------------------------------------
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
config.xml
../config.xml
../../config.xml
../../../config.xml
preference = 10
name = ScrollEnabled, value = false
name = android-minSdkVersion, value = 19
name = BackupWebStorage, value = none
name = SplashMaintainAspectRatio, value = true
name = FadeSplashScreenDuration, value = 300
name = SplashShowOnlyFirstTime, value = false
name = SplashScreen, value = screen
name = SplashScreenDelay, value = 3000
name = AndroidPersistentFileLocation, value = Compatibility
name = GOOGLE_MAPS_ANDROID_API_KEY, value = AIzaSyAP7l8T_EYdETsJfpwtotTE5iDCoMebJlY
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest
> Task :CordovaLib:processDebugManifest
> Task :app:preDebugBuild
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript
> Task :app:checkDebugManifest
> Task :app:generateDebugBuildConfig
> Task :app:prepareLintJar
> Task :app:generateDebugSources
> Task :CordovaLib:compileDebugRenderscript
> Task :CordovaLib:generateDebugBuildConfig
> Task :CordovaLib:generateDebugResValues
> Task :CordovaLib:generateDebugResources
> Task :CordovaLib:packageDebugResources
> Task :CordovaLib:generateDebugRFile
> Task :CordovaLib:prepareLintJar
> Task :CordovaLib:generateDebugSources
> Task :CordovaLib:javaPreCompileDebug
Note: C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :CordovaLib:compileDebugJavaWithJavac
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
> Task :app:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
23 actionable tasks: 23 executed
> Android resource linking failed
C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\app\build\intermediates\merged_manifests\debug\AndroidManifest.xml:34: AAPT: error: resource xml/network_security_config (aka io.ionic.starter:xml/network_security_config) not found.
error: failed processing manifest.
* 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 3m 5s
C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
C:\xampp\htdocs\MyQuestApp\myquestapp\platforms\android\app\build\intermediates\merged_manifests\debug\AndroidManifest.xml:34: AAPT: error: resource xml/network_security_config (aka io.ionic.starter:xml/network_security_config) not found.
error: failed processing manifest.
* 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 3m 5s
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
The reason i want to delete the android studio project located in ionic project is that i think that the ionic builder is not using the ionic project configurations, ionic is using android studio project configs now to make the apk build, and i think this is the error, but i don't know about any command that 'removes' the android studio project config of an ionic project.
Related
Please help me. My React Native app is not running in my mobile. It works fine on the android simulator, but the performance is quiet bad.
The error is:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier"
flag.
Jetifier found 967 file(s) to forward-jetify. Using 2 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 8s
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Com
mand failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
This might be because lower version of Jdk. Please update JDK version supported by Android Studio
For Reff : Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
Try React Native environment to upgrade your environment because there is a thread in here Grovy Error
It's simple , just connect your mobile with Android studio and on the developing mode , then select the device from Android studio and run the project the app will simply open on your phone , unless you don't have any errors in enviornment.
I'm trying to run react native run-android after I update my project file, but whenever I run react-native it throws an error. When I created that project and that command it worked fine but when I edit and add some files like apps/redux, apps/components, screens etc it stopped working. Can anyone tell me why it's not working?
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:compileDebugJavaWithJavac
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
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.3/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 6 executed, 21 up-to-date
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* 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 1m 11s
error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
you either need to create a virtual device or connect a physical device with USB debuging enabled (https://developer.android.com/studio/debug/dev-options).
To create a virtual device, open android studio and select AVD manager from Configure menu and create a new virtual device downloading required packages.
In case you are using a virtual device with Android studio then try to manually run the emulator BEFORE react-native run-android.
(open android studio > Tools > AVD Manager > Create Virtual Device)
https://developer.android.com/studio/run/managing-avds#createavd
Or repeat the official installation guide:
https://reactnative.dev/docs/environment-setup
I took the project I am developing at my workplace home and wanted to run it here on my machine.
I got many many errors which I fixed, but there are some that I don't know how. Maybe you guys know a fix.
\android\app\build\intermediates\external_file_lib_dex_archives\debug\out
this output get generated when building the project from AS.
I read that the fix is to add this: android.enableBuildCache=false to gradle.properties but when I do that I get this error which make 0 sense tbh.
: Cannot parse project property android.enableBuildCache='false ' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.
EDIT: Ok there was an empty space after false hence the second error but even with that corrected I get the first error.
Running it from vsCode gives me: Execution failed for task ':app:processDebugResources'.
EDIT2: Newest Error in AS:
> Task :app:mergeExtDexDebug
java.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:80)
at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:522)
at java.nio.file.Files.newDirectoryStream(Files.java:457)
at java.nio.file.Files.list(Files.java:3451)
at com.android.build.gradle.internal.tasks.DexMergingParams.getAllDexFiles(DexMergingTask.kt:502)
at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:423)
at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:50)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:53)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:217)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:212)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)
> Task :app:transformClassesWithDexBuilderForDebug
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug
> Task :app:mergeDebugJavaResource
> Task :app:mergeExtDexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> java.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out
* 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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 19s
150 actionable tasks: 147 executed, 3 up-to-date
Try to delete the .gradle folder from projectname/android - folder and rebuild. Solved it for me.
I have encountered a similar error before. As a result of my research as a solution
In the android/app/build.gradle file multiDexEnabled true
android {
defaultConfig {
...
targetSdkVersion 28
multiDexEnabled true // here
}
...
}
As Murat Kızılöz suggested, you can get around this by adding multiDexEnabled truein the android/app/build.gradle file.
This is because Android system has a 64K reference limit
In Android, the compilers convert your source code into DEX files. This DEX file
contains the compiled code used to run the app. But there is a limitation with the
DEX file. The DEX file limits the total number of methods that can be referenced
within a single DEX file to 64K i.e. 65,536 methods. So, you cant use more than
64K methods in a particular DEX file. These 64K methods include Android framework
methods, library methods, and methods in our code also. This limit of 64K is
referred to as the "64K reference limit".
So, if our app exceeds 65,536 methods, we will encounter a build error that indicates our app has reached the limit of the Android build architecture.
To get around this, you can manually enable this in the app build.gradle file
You can read more about this at Android Multidex
Try this command in your project root:
cd android && rm -rf .gradle && rm -rf .idea
and then
./gradlew clean
and then build again, works like a charm.
You can solve this issue by deleting the .gradle folder from "NameOfProject/android" and again running Android-Studio, I hoped this is solved. :))
I'm a new in react native so first thing I made is to install react native by running
npm install -g react-native-cli
and after running react-native info
I get this
C:\Users\husam\WebstormProjects\calculator>react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18363
CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU # 2.30GHz
Memory: 815.06 MB / 3.92 GB
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 7, 8, 9
Build Tools: 19.1.0, 28.0.3, 29.0.3
System Images: android-19 | Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6308749
Languages:
Java: 1.8.0_231
Python: 3.7.6
npmPackages:
#react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
after that I create a new project with webstorm from here
[https://www.jetbrains.com/help/webstorm/react-native.html
]
after that I launch the emulator with 19 API level
and then I run the App.js file and I get this
"C:\Program Files\nodejs\node.exe" C:\Users\husam\AppData\Roaming\npm\node_modules\react-native-cli run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Task :app:generatePackageList
> Task :app:preBuild
> Task :app:preDebugBuild
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:bundleDebugJsAndAssets SKIPPED
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders UP-TO-DATE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:copyDebugBundledJs SKIPPED
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:mergeDebugJavaResource UP-TO-DATE
> Task :app:checkDebugDuplicateClasses UP-TO-DATE
> Task :app:desugarDebugFileDependencies UP-TO-DATE
> Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug UP-TO-DATE
> Task :app:mergeExtDexDebug UP-TO-DATE
> Task :app:mergeDexDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :app:mergeDebugNativeLibs UP-TO-DATE
> Task :app:stripDebugDebugSymbols UP-TO-DATE
> Task :app:packageDebug UP-TO-DATE
> Task :app:installDebug
10:21:40 V/ddms: execute: running am get-config
10:21:45 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
10:21:45 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'MY_phone(AVD) - 4.4.2' for app:debug
10:21:45 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
10:21:45 D/Device: Uploading file onto device 'emulator-5554'
10:21:45 D/ddms: Reading file permision of C:\Users\husam\WebstormProjects\calculator\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
10:21:49 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
10:22:25 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:22:25 V/ddms: execute: returning
10:22:25 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
10:22:26 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:22:26 V/ddms: execute: returning
Installed on 1 device.
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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 4m 49s
27 actionable tasks: 2 executed, 25 up-to-date
info Connecting to the development server...
adb.exe: error: closed
info Starting the app on "emulator-5554"...
warn Failed to connect to development server using "adb reverse": Command failed: C:\Users\husam\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.calculator/.MainActivity }
the error as showing in the log Is about the adb but I can use the adb command to install and get logcat in both the emulator and the real devices without any error
after searching on the internet I tried to run this two commands
adb reconnect
adb reverse tcp:8081 tcp:8081
but I get the same error as following
C:\Users\husam\WebstormProjects\calculator>adb reconnect
reconnecting 4203605bb24a3200 [device]
C:\Users\husam\WebstormProjects\calculator>adb reverse tcp:8081 tcp:8081
adb.exe: error: closed
the code that I run is the default one that is created by react native
also the app is installed successfully on my emulator but when I run it I get
an error tells me the app will stop
also I noted when I launch the emulator it's gives me this error
In React-Native documentation, it is mentioned that it is better to remove react-native-cli because it is causing some issues.
I had the same problem, and it is solved when I changed the API of the emulator from 19 to 29. So, the problem is the API version.
But Also make sure that you run >npm install.
Also, I used genymotion for the emulator, I suggest that you use it, and open the emulator. and open two terminals, in the first one type >react-native start
and in another terminal type >npx react-native run-android. Moreover, make sure that you don't have any problem with the port.
Hope this helps.
today I just created my first React Native project but when I tried to run it on my avd just like;
react-native run-android
but it always gives this:
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:bundleDebugJsAndAssets SKIPPED
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk/jre contains a valid JDK installation.
* 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 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 26s
12 actionable tasks: 5 executed, 7 up-to-date
error 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
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
I don't know what should I do and I totally need your help.
Thanks for your attention.
It was a problem with system looking at the JRE folder i.e. /usr/lib/jvm/java-8-openjdk/jre. If we look in there, there is no Tools.jar, hence the error.
You can create environment variables JAVA_HOME :
Inside Variable value add your JDK in place of jdk1.8.0_11
Now edit yout PATH variable to add JAVA_HOME :
Now try to run the command again .
OR
Check this path C:\Program Files\Android\Android Studio\jre\lib if you find tools.jar there then try setting JAVA_HOME=C:\Program Files\Android\Android Studio\jre in above enviroment variable.
For Linux Users -
Edit the system Path file /etc/profile
sudo gedit /etc/profile
Add following lines in end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
In place of jdk1.7.0 add your JDK version.
Then Log out and Log in ubuntu for setting up the paths...
Hope it works !
Hi. You need to check if JDK is properly installed and verify that you have added the environment variables JAVA_HOME & JDK_HOME.