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 :

Erreur "The application has stopped unexpectedly. Please try again"


Sujet :

Android

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Novembre 2015
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Erreur "The application has stopped unexpectedly. Please try again"
    Bonsoir a tous,

    Je développe une application sur Android Studio, je trouve aucune erreur sur mon code du coup je lance l'émulateur et j'ai le message "The application has stopped unexpectedly. Please try again" et la j'ai bcp ligne en rouge qui s'affiche dans le logcat, Problème je ne comprends pas les erreurs dit... Je débute en programmation Android. Si quelqu'un pouvais m'aider. J'affiche le message juste en dessous, Merci d'avance.

    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
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    11-01 20:06:17.270      339-339/com.example.kevin.quizzapp2 E/Database﹕ Failure 1 (AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY) on 0x2d2840 when preparing 'CREATE TABLE IF NOT EXISTS Question(idINTEGER PRIMARY KEY AUTOINCREMENT,questionTEXT,reponseTEXTt,optionATEXT,optionBTEXT,optionCTEXT)'.
    11-01 20:06:17.311      339-339/com.example.kevin.quizzapp2 E/SQLiteOpenHelper﹕ Couldn't open QuizzApp for writing (will try read-only):
        android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY: CREATE TABLE IF NOT EXISTS Question(idINTEGER PRIMARY KEY AUTOINCREMENT,questionTEXT,reponseTEXTt,optionATEXT,optionBTEXT,optionCTEXT)
                at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
                at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1763)
                at com.example.kevin.quizzapp2.MySQLiteOpenHelper.onCreate(MySQLiteOpenHelper.java:45)
                at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126)
                at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
                at com.example.kevin.quizzapp2.MySQLiteOpenHelper.getAllQuestion(MySQLiteOpenHelper.java:82)
                at com.example.kevin.quizzapp2.QuizzActivity.onCreate(QuizzActivity.java:29)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
                at android.app.ActivityThread.access$1500(ActivityThread.java:117)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:123)
                at android.app.ActivityThread.main(ActivityThread.java:3683)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:507)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
                at dalvik.system.NativeStart.main(Native Method)
    11-01 20:06:17.331      339-339/com.example.kevin.quizzapp2 D/AndroidRuntime﹕ Shutting down VM
    11-01 20:06:17.340      339-339/com.example.kevin.quizzapp2 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40015560)
    11-01 20:06:17.391      339-339/com.example.kevin.quizzapp2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kevin.quizzapp2/com.example.kevin.quizzapp2.QuizzActivity}: android.database.sqlite.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.example.kevin.quizzapp2/databases/QuizzApp
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
                at android.app.ActivityThread.access$1500(ActivityThread.java:117)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:123)
                at android.app.ActivityThread.main(ActivityThread.java:3683)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:507)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: android.database.sqlite.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.example.kevin.quizzapp2/databases/QuizzApp
                at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:199)
                at com.example.kevin.quizzapp2.MySQLiteOpenHelper.getAllQuestion(MySQLiteOpenHelper.java:82)
                at com.example.kevin.quizzapp2.QuizzActivity.onCreate(QuizzActivity.java:29)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    ************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    ************at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    ************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    ************at android.os.Handler.dispatchMessage(Handler.java:99)
    ************at android.os.Looper.loop(Looper.java:123)
    ************at android.app.ActivityThread.main(ActivityThread.java:3683)
    ************at java.lang.reflect.Method.invokeNative(Native Method)
    ************at java.lang.reflect.Method.invoke(Method.java:507)
    ************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    ************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    ************at dalvik.system.NativeStart.main(Native Method)

  2. #2
    Membre expérimenté Avatar de Nico02
    Homme Profil pro
    Developpeur Java/JEE
    Inscrit en
    Février 2011
    Messages
    728
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Developpeur Java/JEE
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2011
    Messages : 728
    Points : 1 622
    Points
    1 622
    Par défaut
    Salut,

    tu n'as pas mis d'espace entre 'id' et 'INTEGER' dans le code qui génère ta table.

    Question(idINTEGER ... ----------> Question(id INTEGER ...

    D'ailleurs on voit que c'est le cas pour toute les colonnes, j’imagine que tu as du écrire un truc dans le style

    String sql = "blabla" + KEY_ID + "INTEGER PRIMARY KEY AUTOINCREMENT, " + etc... sauf qu'en faisant ça tu ne mets d'espace entre 'KEY_ID' et la suite de ta chaine de caractère. Pareil il n'y a pas d'espace après les virgules dans ton code.

    Petit point bonus, si effectivement tu enchaines les concaténation comme ça, utilise un StringBuilder à la place qui est moins groumant en ressource lors de la construction de la chaine.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    StringBuilder sb = new StringBuilder( "CREATE TABLE IF NOT EXISTS Question" );
    sb.append( "id INTEGER PRIMARY KEY AUTOINCREMENT, "); // remarque que j'ai mis un espace après la virgule
    sb.append( ..... );
     
    String sqlStmt = sb.toString();
    Cdt.

  3. #3
    Expert confirmé
    Avatar de Hephaistos007
    Profil pro
    Enseignant Chercheur
    Inscrit en
    Décembre 2004
    Messages
    2 493
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 493
    Points : 4 166
    Points
    4 166
    Par défaut
    Je profites de ce post pour rappeler cet ancien projet, qui peut éviter ce genre d'erreur : http://gendroid.univ-pau.fr/

    Il suffit d'uploader une description SQLLite de la base pour que le code du Helper soit généré.

    @+
    Il vaut mieux mobiliser son intelligence sur des conneries que mobiliser sa connerie sur des choses intelligentes --- devise SHADOKS

    Kit de survie Android : mon guide pour apprendre à programmer sur Android, mon tutoriel sur les web services et enfin l'outil en ligne pour vous faire gagner du temps - N'oubliez pas de consulter la FAQ Android

Discussions similaires

  1. THE APPLICATION HAS STOPPED UNEXPECTDLY TRY AGAIN
    Par mohamed sarr dans le forum Android
    Réponses: 1
    Dernier message: 17/09/2014, 13h17
  2. the application has stopped unexpectedly
    Par zerkos dans le forum Android
    Réponses: 15
    Dernier message: 08/01/2013, 17h35
  3. Réponses: 5
    Dernier message: 11/10/2012, 16h01
  4. Réponses: 1
    Dernier message: 01/05/2012, 13h33
  5. CVCamera (the application has stopped unexpectly)
    Par nizkowsky dans le forum Android
    Réponses: 4
    Dernier message: 16/05/2011, 10h02

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