質問編集履歴

4

修正

2018/06/03 19:14

投稿

sena14
sena14

スコア109

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- ストアからダウンロードしてandroid7.0以前の端末で試したり、8.0の端末でUSBデバッグをした際は起動するのですが、ストアからダウンロードして8.0で開こうとすると強制終了してしまいます。playConsoleの情報を見る限り起動時データベースを読み込むところでillegalstateexceptionでクラッシュしているようです。
5
+ ストアからダウンロードして~~android7.0以前の端末で試したり、8.0の端末でUSBデバッグをした際は起動するのですが、ストアからダウンロードして8.0で~~開こうとすると強制終了してしまいます。playConsoleの情報を見る限り起動時データベースを読み込むところでillegalstateexceptionでクラッシュしているようです。
6
6
 
7
7
  USBデバッグだと強制終了しなかったりと何が原因なのかつかめない状態でいます。
8
8
 
@@ -34,6 +34,8 @@
34
34
 
35
35
  エラーメッセージを追加しました
36
36
 
37
+ 8.0でも起動できる機種起動できない機種があることが分かりました
38
+
37
39
 
38
40
 
39
41
  java.lang.RuntimeException:

3

エラーメッセージの追記

2018/06/03 19:14

投稿

sena14
sena14

スコア109

test CHANGED
File without changes
test CHANGED
@@ -32,6 +32,54 @@
32
32
 
33
33
  の行でillegalstateexceptionが発生しているようです。
34
34
 
35
+ エラーメッセージを追加しました
36
+
37
+
38
+
39
+ java.lang.RuntimeException:
40
+
41
+ at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2917)
42
+
43
+ at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2978)
44
+
45
+ at android.app.ActivityThread.-wrap14 (ActivityThread.java)
46
+
47
+ at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1628)
48
+
49
+ at android.os.Handler.dispatchMessage (Handler.java:102)
50
+
51
+ at android.os.Looper.loop (Looper.java:154)
52
+
53
+ at android.app.ActivityThread.main (ActivityThread.java:6646)
54
+
55
+ at java.lang.reflect.Method.invoke (Native Method)
56
+
57
+ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1468)
58
+
59
+ at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)
60
+
61
+ Caused by: java.lang.IllegalStateException:
62
+
63
+ at android.database.CursorWindow.nativeGetLong (Native Method)
64
+
65
+ at android.database.CursorWindow.getLong (CursorWindow.java:524)
66
+
67
+ at android.database.CursorWindow.getInt (CursorWindow.java:591)
68
+
69
+ at android.database.AbstractWindowedCursor.getInt (AbstractWindowedCursor.java:69)
70
+
71
+ at pakcage.SQLMyWritable.load (SQLMyWritable.kt:59)
72
+
73
+ at pakcage.TitleActivity.loadSaveData (TitleActivity.kt:67)
74
+
75
+ at pakcage.TitleActivity.onCreate (TitleActivity.kt:24)
76
+
77
+ at android.app.Activity.performCreate (Activity.java:6912)
78
+
79
+ at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126)
80
+
81
+ at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2870)
82
+
35
83
 
36
84
 
37
85
 

2

追記

2018/06/01 04:58

投稿

sena14
sena14

スコア109

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,14 @@
26
26
 
27
27
 
28
28
 
29
+ 更に確認したところ
30
+
31
+ saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
32
+
33
+ の行でillegalstateexceptionが発生しているようです。
34
+
35
+
36
+
29
37
 
30
38
 
31
39
 

1

追記

2018/05/31 16:00

投稿

sena14
sena14

スコア109

test CHANGED
File without changes
test CHANGED
@@ -16,6 +16,18 @@
16
16
 
17
17
 
18
18
 
19
+ 追記
20
+
21
+ SQLMyWritableのloadを呼ぶと強制終了してしまうことからinitLoad()として一部に減らしてみたところ強制終了が防げました。
22
+
23
+ 処理が多すぎて強制終了してしまうということなのでしょうか?
24
+
25
+ どのように変更すれば対応できますでしょうか?よろしくお願いします。
26
+
27
+
28
+
29
+
30
+
19
31
 
20
32
 
21
33
  ```ここに言語を入力
@@ -40,12 +52,6 @@
40
52
 
41
53
  import android.widget.Toast
42
54
 
43
- import com.google.android.gms.ads.AdRequest
44
-
45
- import com.google.android.gms.ads.AdView
46
-
47
- import com.google.android.gms.ads.MobileAds
48
-
49
55
 
50
56
 
51
57
  class TitleActivity : AppCompatActivity() {
@@ -74,18 +80,6 @@
74
80
 
75
81
  this.myBgm.start3()
76
82
 
77
-
78
-
79
-
80
-
81
- MobileAds.initialize(this, "id")
82
-
83
- adView()
84
-
85
-
86
-
87
-
88
-
89
83
  }
90
84
 
91
85
 
@@ -114,111 +108,219 @@
114
108
 
115
109
 
116
110
 
117
- //名前入力
118
-
119
- fun decideName(view: View) {
120
-
121
- val editText = findViewById<EditText>(R.id.nameEditText)
122
-
123
- if (editText.text.isEmpty()) {
124
-
125
- Toast.makeText(this, "名前を入力してください", Toast.LENGTH_SHORT).show()
126
-
127
- } else {
128
-
129
- saveData.myCharacter.Name = editText.text.toString()
130
-
131
- dataSave()
132
-
133
- val event = Event(this, 0, saveData,myBgm)
111
+ //セーブ
112
+
113
+ fun dataSave() {
114
+
115
+ val sqlMyWritable = SQLMyWritable(this)
116
+
117
+ sqlMyWritable.save(saveData)
118
+
119
+ }
120
+
121
+
122
+
123
+ //セーブデータ読み込み
124
+
125
+ fun loadSaveData() {
126
+
127
+ val sqlMyWritable = SQLMyWritable(this)
128
+
129
+ saveData = sqlMyWritable.load()
130
+
131
+ }
132
+
133
+
134
+
135
+ }
136
+
137
+ ```
138
+
139
+
140
+
141
+ ```ここに言語を入力
142
+
143
+
144
+
145
+
146
+
147
+ import android.content.ContentValues
148
+
149
+ import android.content.Context
150
+
151
+ import android.database.Cursor
152
+
153
+
154
+
155
+ class SQLMyWritable(val context: Context) {
156
+
157
+
158
+
159
+ fun initLoad(): SaveData {
160
+
161
+ val openHelper = SQLMyOpenHelper(context)
162
+
163
+ val database = openHelper.getWritableDatabase()
164
+
165
+
166
+
167
+ var cursor: Cursor? = null
168
+
169
+ cursor = database.query(
170
+
171
+ SQLMyContract.SaveData.TABLE_NAME,
172
+
173
+ null, null, null, null, null, null, null
174
+
175
+ )
176
+
177
+ val saveData = SaveData()
178
+
179
+
180
+
181
+ cursor.moveToFirst()
182
+
183
+
184
+
185
+ saveData.myCharacter.Name = cursor.getString(cursor.getColumnIndex(SQLMyContract.SaveData.MY_NAME))
186
+
187
+ saveData.eventData.initEvent = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.INITEVENT)))
188
+
189
+
190
+
191
+ return saveData
192
+
193
+ }
194
+
195
+
196
+
197
+ //読み込み
198
+
199
+ fun load(): SaveData {
200
+
201
+ val openHelper = SQLMyOpenHelper(context)
202
+
203
+ val database = openHelper.getWritableDatabase()
204
+
205
+
206
+
207
+ var cursor: Cursor? = null
208
+
209
+ cursor = database.query(
210
+
211
+ SQLMyContract.SaveData.TABLE_NAME,
212
+
213
+ null, null, null, null, null, null, null
214
+
215
+ )
216
+
217
+ val saveData = SaveData()
218
+
219
+
220
+
221
+ cursor.moveToFirst()
222
+
223
+
224
+
225
+ saveData.myCharacter.Name = cursor.getString(cursor.getColumnIndex(SQLMyContract.SaveData.MY_NAME))
226
+
227
+ saveData.myCharacter.HP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_HP))
228
+
229
+ saveData.myCharacter.MaxHP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MAX_HP))
230
+
231
+ saveData.myCharacter.MP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MP))
232
+
233
+ saveData.myCharacter.MaxMP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MAX_MP))
234
+
235
+ saveData.myCharacter.STR = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_STR))
236
+
237
+ saveData.myCharacter.DEF = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_DEF))
238
+
239
+ saveData.myCharacter.AGI = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_AGI))
240
+
241
+ saveData.myCharacter.INT = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_INT))
242
+
243
+ saveData.myCharacter.EXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_EXP))
244
+
245
+ saveData.myCharacter.theEXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_THE_EXP))
246
+
247
+ saveData.myCharacter.EXP_BONUS = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_EXP_BONUS))
248
+
249
+
250
+
251
+ saveData.eventData.boss1 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS1)))
252
+
253
+ saveData.eventData.boss2 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS2)))
254
+
255
+ saveData.eventData.boss3 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS3)))
256
+
257
+ saveData.eventData.boss4 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS4)))
258
+
259
+ saveData.eventData.boss5 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS5)))
260
+
261
+ saveData.eventData.boss6 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS6)))
262
+
263
+ saveData.eventData.boss7 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS7)))
264
+
265
+ saveData.eventData.boss8 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS8)))
266
+
267
+ saveData.eventData.boss9 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS9)))
268
+
269
+ saveData.eventData.boss10 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS10)))
270
+
271
+ saveData.eventData.initEvent = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.INITEVENT)))
272
+
273
+
274
+
275
+ saveData.floor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.NOW_FLOOR))
276
+
277
+ saveData.isBattle = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.IS_BATTLE)))
278
+
279
+ saveData.enemyHP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ENEMY_HP))
280
+
281
+ saveData.enemyNo = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ENEMY_NO))
282
+
283
+
284
+
285
+ saveData.maxFloor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MAX_FLOOR))
286
+
287
+ saveData.startFloor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.START_FLOOR))
288
+
289
+
290
+
291
+ saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
292
+
293
+ saveData.escapeTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ESCAPE_TIMES))
294
+
295
+ saveData.gameOverTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.GAME_OVER_TIMES))
296
+
297
+
298
+
299
+ saveData.EXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.EXP))
300
+
301
+ database.close()
302
+
303
+ cursor.close()
304
+
305
+ return saveData
306
+
307
+ }
308
+
309
+
310
+
311
+ fun returnBoolean(i: Int): Boolean {
312
+
313
+ var b = false
314
+
315
+ when (i) {
316
+
317
+ 0 -> b = false
318
+
319
+ 1 -> b = true
134
320
 
135
321
  }
136
322
 
137
- }
138
-
139
-
140
-
141
- //セーブ
142
-
143
- fun dataSave() {
144
-
145
- val sqlMyWritable = SQLMyWritable(this)
146
-
147
- sqlMyWritable.save(saveData)
148
-
149
- }
150
-
151
-
152
-
153
- //セーブデータ読み込み
154
-
155
- fun loadSaveData() {
156
-
157
- val sqlMyWritable = SQLMyWritable(this)
158
-
159
- saveData = sqlMyWritable.load()
160
-
161
- }
162
-
163
-
164
-
165
- override fun onResume() {
166
-
167
- super.onResume()
323
+ return b
168
-
169
- myBgm.start3()//BGM再生
170
-
171
- if (mAdView != null) {
172
-
173
- mAdView.resume()
174
-
175
- }
176
-
177
- }
178
-
179
-
180
-
181
- override fun onPause() {
182
-
183
- if (mAdView != null) {
184
-
185
- mAdView.pause()
186
-
187
- }
188
-
189
- super.onPause()
190
-
191
- myBgm.stop3()//BGM停止
192
-
193
- }
194
-
195
-
196
-
197
- override fun onDestroy() {
198
-
199
- if (mAdView != null) {
200
-
201
- mAdView.destroy()
202
-
203
- }
204
-
205
- super.onDestroy()
206
-
207
- }
208
-
209
-
210
-
211
-
212
-
213
- //広告
214
-
215
- private fun adView(){
216
-
217
- mAdView = findViewById(R.id.adView)
218
-
219
- val adRequest = AdRequest.Builder().build()
220
-
221
- mAdView.loadAd(adRequest)
222
324
 
223
325
  }
224
326