wake-up-neo.com

reaktives Ausführen von Android mit Fehler fehlgeschlagen: Ausführung fehlgeschlagen für Task ': app: dexDebug'

Ich verwende Windows 8.1. mit react-native-cli: 1.0.0 und react-native: 0.31.0 

Nachdem ich react-native-maps zum Projekt hinzugefügt hatte, führte ich den Befehl react-native upgrade aus und gabYzu allen Fragen. Dann verknüpfte deps mit rnpm link sowie Änderungen in der MainApplication.Java-Datei.

Hier sind Änderungen an MainApplication.Java:

// Other imports ...
import com.airbnb.Android.react.maps.MapsPackage;

public class MainApplication extends Application implements ReactApplication {

 private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
       return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
         new MainReactPackage(),
         new MapsPackage() // I have added this for react-native-maps
      );
    }
  };

 @Override
 public ReactNativeHost getReactNativeHost() {
   return mReactNativeHost;
 }
}

Jetzt erhalte ich eine Fehlermeldung, wenn ich den Befehl ausführt: react-native run-Android

λ react-native run-Android                                                                    
JS server already running.                                                                    
Running C:\Program Files (x86)\Android\android-sdk/platform-tools/adb reverse tcp:8081 tcp:808
1                                                                                             
Building and installing the app on the device (cd Android && gradlew.bat installDebug...      
:app:preBuild UP-TO-DATE                                                                      
:app:preDebugBuild UP-TO-DATE                                                                 
:app:checkDebugManifest                                                                       
:app:preReleaseBuild UP-TO-DATE                                                               
:react-native-maps:compileLint                                                                
:react-native-maps:copyReleaseLint UP-TO-DATE                                                 
:react-native-maps:preBuild UP-TO-DATE                                                        
:react-native-maps:preReleaseBuild UP-TO-DATE                                                 
:react-native-maps:checkReleaseManifest                                                       
:react-native-maps:preDebugAndroidTestBuild UP-TO-DATE                                        
:react-native-maps:preDebugBuild UP-TO-DATE                                                   
:react-native-maps:preDebugUnitTestBuild UP-TO-DATE                                           
:react-native-maps:preReleaseUnitTestBuild UP-TO-DATE                                         
:react-native-maps:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE                  
:react-native-maps:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE               
:react-native-maps:prepareComAndroidSupportSupportV42321Library UP-TO-DATE                    
:react-native-maps:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE                       
:react-native-maps:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE                       
:react-native-maps:prepareComFacebookFrescoFresco0110Library UP-TO-DATE                       
:react-native-maps:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE                
:react-native-maps:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE            
:react-native-maps:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE         
:react-native-maps:prepareComFacebookReactReactNative0310Library UP-TO-DATE                   
:react-native-maps:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE                    
:react-native-maps:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE            
:react-native-maps:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE        
:react-native-maps:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE            
:react-native-maps:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE                        
:react-native-maps:prepareReleaseDependencies                                                 
:react-native-maps:compileReleaseAidl UP-TO-DATE                                              
:react-native-maps:compileReleaseRenderscript UP-TO-DATE                                      
:react-native-maps:generateReleaseBuildConfig UP-TO-DATE                                      
:react-native-maps:generateReleaseAssets UP-TO-DATE                                           
:react-native-maps:mergeReleaseAssets UP-TO-DATE                                              
:react-native-maps:generateReleaseResValues UP-TO-DATE                                        
:react-native-maps:generateReleaseResources UP-TO-DATE                                        
:react-native-maps:mergeReleaseResources UP-TO-DATE                                           
:react-native-maps:processReleaseManifest UP-TO-DATE                                          
:react-native-maps:processReleaseResources UP-TO-DATE                                         
:react-native-maps:generateReleaseSources UP-TO-DATE                                          
:react-native-maps:processReleaseJavaRes UP-TO-DATE                                           
:react-native-maps:compileReleaseJavaWithJavac UP-TO-DATE                                     
:react-native-maps:extractReleaseAnnotations UP-TO-DATE                                       
:react-native-maps:mergeReleaseProguardFiles UP-TO-DATE                                       
:react-native-maps:packageReleaseJar UP-TO-DATE                                               
:react-native-maps:compileReleaseNdk UP-TO-DATE                                               
:react-native-maps:packageReleaseJniLibs UP-TO-DATE                                           
:react-native-maps:packageReleaseLocalJar UP-TO-DATE                                          
:react-native-maps:packageReleaseRenderscript UP-TO-DATE                                      
:react-native-maps:packageReleaseResources UP-TO-DATE                                         
:react-native-maps:bundleRelease UP-TO-DATE                                                   
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE                                
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE                             
:app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE                                  
:app:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE                                     
:app:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE                                     
:app:prepareComFacebookFrescoFresco0110Library UP-TO-DATE                                     
:app:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE                              
:app:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE                          
:app:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE                       
:app:prepareComFacebookReactReactNative0310Library UP-TO-DATE                                 
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE                                  
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE                          
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE                      
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE                          
:app:prepareNativeBaseDemoReactNativeMapsUnspecifiedLibrary 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:bundleDebugJsAndAssets SKIPPED                                                           
:app:processDebugManifest UP-TO-DATE                                                          
:app:processDebugResources UP-TO-DATE                                                         
:app:generateDebugSources UP-TO-DATE                                                          
:app:processDebugJavaRes UP-TO-DATE                                                           
:app:compileDebugJavaWithJavac UP-TO-DATE                                                     
:app:compileDebugNdk UP-TO-DATE                                                               
:app:compileDebugSources UP-TO-DATE                                                           
:app:preDexDebug UP-TO-DATE                                                                   
:app:dexDebug                                                                                 
  Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:                                         
  Unknown source file : com.Android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;                                                                         
  Unknown source file :   at com.Android.dx.merge.DexMerger.readSortableTypes(DexMerger.Java:596)                                                                                             
  Unknown source file :   at com.Android.dx.merge.DexMerger.getSortedTypes(DexMerger.Java:554)  
  Unknown source file :   at com.Android.dx.merge.DexMerger.mergeClassDefs(DexMerger.Java:535)  
  Unknown source file :   at com.Android.dx.merge.DexMerger.mergeDexes(DexMerger.Java:171)      
  Unknown source file :   at com.Android.dx.merge.DexMerger.merge(DexMerger.Java:189)           
  Unknown source file :   at com.Android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.Java:502)                                                                                          
  Unknown source file :   at com.Android.dx.command.dexer.Main.runMonoDex(Main.Java:334)        
  Unknown source file :   at com.Android.dx.command.dexer.Main.run(Main.Java:277)               
  Unknown source file :   at com.Android.dx.command.dexer.Main.main(Main.Java:245) 

  Unknown source file :   at com.Android.dx.command.Main.main(Main.Java:106)       
:app:dexDebug FAILED                                                                          

FAILURE: Build failed with an exception.                                                      

* What went wrong:                                                                            
Execution failed for task ':app:dexDebug'.                                                    
> com.Android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: 
Process 'command 'C:\Program Files\Java\jdk1.8.0_102\bin\Java.exe'' finished with non-zero exit value 2                                                                                     

* 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: 50.673 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             

Ich habe keine Ahnung von diesem Fehler. Ich sah einige ähnliche Fragen, konnte aber keine Antwort finden. Ich bin neu in der Entwicklung von React-Native und Android, daher habe ich Schwierigkeiten, diese Dinge zu verstehen.

5
Hiren

Dieses Problem ist normalerweise auf die Abhängigkeit von neuen Komponenten zurückzuführen. Ich kann sehen, dass Sie React-Native-Maps installiert haben.

sie können es lösen, indem Sie das Projekt reinigen.

  1. In Ihrem React Native-Projekt:

cd Android/&& ./gradlew sauber

  1. gehen Sie zurück und versuchen Sie es erneut.

cd .. && reagieren-native run-Android

24

Verwenden Sie diese Schritte

1.) cd android

2.) gradle sauber

3.) Führen Sie jetzt das Projekt aus.

Dieser Fehler tritt in meinem System auf, wenn der Emulator aktualisiert wird.

0
Surbhit Rao

um genauer zu sein:

Ändern Sie in Ihrer MainApplication.Java-Datei,

protected boolean getUseDeveloperSupport() { { <-----

auf diesem

public boolean getUseDeveloperSupport() { <-----

das hat es zumindest für mich gebaut

0
Rajan Maharjan

Das Problem für mich war, dass der Packager vom vorherigen Build im Hintergrund ausgeführt wurde.

Sie können einfach versuchen, den Packager-Server zu schließen und mit zu starten 

react-native run-Android

Das war für mein Problem erfolgreich.

0
Burak Tokak

führen Sie dies einfach aus dem Stammverzeichnis Ihres Projekts mit cmd aus:

cd Android && gradlew clean

0
Rajon Tanducar