Débuter avec React Native. J'ai installé le SDK Android, le SDK Java et les dépendances Android. Je reçois le message d'erreur suivant lors de l'exécution d'une application de démonstration sur mon terminal.
J'ai mon émulateur Galaxy en cours d'exécution:
~ emulator @galaxy
HAXM is working and emulator runs in fast virt mode
emulator: UpdateChecker: skipped version check
Maintenant je le lance:
~ react-native run-Android
Starting JS server...
Building and installing the app on the device (cd Android && ./gradlew installDebug)...
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
Java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an Android_HOME environment variable.
at com.Android.build.gradle.internal.SdkHandler.getAndCheckSdkFolder(SdkHandler.Java:102)
at com.Android.build.gradle.internal.SdkHandler.getSdkLoader(SdkHandler.Java:112)
at com.Android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.Java:86)
at com.Android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:507)
at com.Android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:455)
at com.Android.build.gradle.BasePlugin$_createTasks_closure13_closure17.doCall(BasePlugin.groovy:415)
at com.Android.build.gradle.BasePlugin$_createTasks_closure13_closure17.doCall(BasePlugin.groovy)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.Java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.Java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.Java:292)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.Java:1015)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.Java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.Java:45)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.Java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.Java:112)
at com.Android.build.gradle.internal.profile.SpanRecorders$2.call(SpanRecorders.groovy:52)
at com.Android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.Java:48)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.Java:189)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.Java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.Java:124)
at com.Android.build.gradle.internal.profile.SpanRecorders.record(SpanRecorders.groovy:54)
at com.Android.build.gradle.BasePlugin$_createTasks_closure13.doCall(BasePlugin.groovy:414)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.Java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.Java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.Java:292)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.Java:1015)
at groovy.lang.Closure.call(Closure.Java:423)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.Java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.Java:25)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.Java:87)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.Java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.Java:93)
at com.Sun.proxy.$Proxy11.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.Java:67)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.Java:61)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.Java:487)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.Java:85)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.Java:47)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.Java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.Java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.Java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.Java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.Java:90)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.Java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.Java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:28)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.Java:50)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.Java:27)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.Java:40)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.Java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.Java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.Java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:22)
at org.gradle.launcher.Main.doAction(Main.Java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.Java:45)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.Java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.Java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.Java:23)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:57)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:606)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.Java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.Java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.Java:61)
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/jonathanbello/Documents/Personal-Projects/Javascript/React-Native/WeatherApp/Android/app/build.gradle' line: 102
* What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an Android_HOME environment variable.
* 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: 7.565 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
Système: - OSX Yosemite - noeud v 5.5
Dans Android Studio: Fichier -> Structure du projet -> Emplacement du SDK Android
Copier le chemin du SDK Android
react-native run-Android
.Voici comment créer un fonctionnement natif de la réaction avec Android sous Mac OSX:
Ajouter PATH dans .base_profile
export Android_HOME=/Users/UserName/Library/Android/sdk
export PATH=$PATH:$Android_HOME/tools:$Android_HOME/platform-tools
Placez le fichier local.properties
dans le dossier project_name/Android/
.
Éditez local.properties
puis ajoutez sdk.dir=/Users/UserName/Library/Android/sdk
.
Exécutez la commande Android
pour mettre à jour les packages requis . Pour RN 0.32, sa
Exécuter le studio Android ou la commande Android avd
pour ouvrir un émulateur
react-native run-Android
react-native start
pour déclencher le serveur de pont.Si vous utilisez Android Studio, suivez les étapes ci-dessous.
Ajouter le chemin de studio Android à votre variable d'environnement
nano ~/.bash_profile
Ajouter les lignes ci-dessous:
export Android_HOME=/YOUR_PATH_TO/Android-sdk
export PATH=$Android_HOME/platform-tools:$PATH
export PATH=$Android_HOME/tools:$PATH
Sous Linux sans studio Android:
Premières vérifications: Vous avez déjà téléchargé et décompressé le SDK Android et exécuté la commande Android pour installer un SDK de développement réel?
Toujours pas trouvé lors de la construction et en cours d'exécution. Ensuite, le problème peut être que le fichier local.properties doit se trouver dans le même répertoire que Gradile pour que Gradle le trouve lors de la création et de l'exécution de adb.
Pour mon projet d’utilisation, j’avais besoin de placer le fichier local.properties dans le dossier Myprojectname/Android/et tout a commencé à fonctionner.
Comme j'ai décompressé le SDK pour télécharger mon chemin dans le fichier est la suivante: sdk.dir =/home/UTILISATEUR/Téléchargements/Android-sdk-linux