IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

map fonctionne sur smartphone mais crash sur emulator


Sujet :

Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 30
    Points : 22
    Points
    22
    Par défaut map fonctionne sur smartphone mais crash sur emulator
    Bonjour,
    j'essaye de faire fonctionner google maps sur android en utilisant SupportFragmentManager. cela fonctionne bien sur mon smartphone (4.3), mais quand je l'execute sur un emulateur (android sdk, avd) targets comme google api's (API 17,18,22) elle crash et on me sort ces exceptions :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    06-04 23:22:26.662: W/GooglePlayServicesUtil(2844): Google Play services 
    out of date.  Requires 7571000 but found 6774470
    06-04 23:22:26.676: D/AndroidRuntime(2844): Shutting down VM
    06-04 23:22:26.676: E/AndroidRuntime(2844): FATAL EXCEPTION: main
    06-04 23:22:26.676: E/AndroidRuntime(2844): Process: com.example.radaroc,     PID: 2844
    06-04 23:22:26.676: E/AndroidRuntime(2844): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.radaroc/com.example.radaroc.SupportMapActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.setOnMapClickListener(com.google.android.gms.maps.GoogleMap$OnMapClickListener)' on a null object reference
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread.access$800(ActivityThread.java:151)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.os.Handler.dispatchMessage(Handler.java:102)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.os.Looper.loop(Looper.java:135)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread.main(ActivityThread.java:5257)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at java.lang.reflect.Method.invoke(Native Method)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at java.lang.reflect.Method.invoke(Method.java:372)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    06-04 23:22:26.676: E/AndroidRuntime(2844): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.setOnMapClickListener(com.google.android.gms.maps.GoogleMap$OnMapClickListener)' on a null object reference
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at com.example.radaroc.SupportMapActivity.onCreate(SupportMapActivity.java:66)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.Activity.performCreate(Activity.java:5990)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
    06-04 23:22:26.676: E/AndroidRuntime(2844):     ... 10 more
    voila ma méthode onCreate :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_support_map);
     
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
     
        // Showing status
        if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available
     
            int requestCode = 10;
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
            dialog.show();
     
        }else { // Google Play Services are available           
            FragmentManager myFM = getSupportFragmentManager();
     
            final SupportMapFragment fm = (SupportMapFragment) myFM
                            .findFragmentById(R.id.map);
     
     
            //SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
     
            googleMap = fm.getMap();// fm.getMapAsync(this);
            googleMap.setMyLocationEnabled(true);           
            getSupportLoaderManager().initLoader(0, null, this);            
        }        
    }
    et voila mon layout xml

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >
     
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />
     
    </RelativeLayout>
    voila mon avd manager :
    Nom : Capture.PNG
Affichages : 110
Taille : 20,3 Ko

  2. #2
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Salut normal il te faut les google playservices sur l'emulateur qui n'est pas présent de base.

    Il me semble qu'il y a une manipulation à faire pour que cela marche sur emulateur

    Voilà http://hmkcode.com/run-google-map-v2...roid-emulator/

    - Télécharger les deux .apk Files

    Google Play services apk: https://play.google.com/store/apps/d...le.android.gms
    Google Play store apk ( faut le trouver)

    - Installer les deux apks en ligne de commande

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    adb install "le nom de tes apks"
    Après normalement lance l'emulateur sur une version >3 ca devrait marcher
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

Discussions similaires

  1. Réponses: 1
    Dernier message: 28/03/2007, 19h20
  2. Eval qui fonctionne sur Firefox mais pas sur IE :D
    Par Comawhite dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 30/10/2006, 11h31
  3. [2.0] connexion qui fonctionne chez moi mais pas sur un autre pc
    Par Lorenzeb dans le forum Accès aux données
    Réponses: 1
    Dernier message: 13/09/2006, 17h47
  4. Réponses: 4
    Dernier message: 14/03/2006, 10h04
  5. Réponses: 2
    Dernier message: 23/11/2005, 17h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo