質問編集履歴
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
アプリを開こうとすると強制終了してしまい困っています。
|
2
2
|
|
3
|
-
ストアからダウンロードしてandroid7.0以前の端末で試したり、8.0の端末でUSBデバッグをした際は起動するのですが、ストアからダウンロードして8.0で開こうとすると強制終了してしまいます。playConsoleの情報を見る限り起動時データベースを読み込むところでillegalstateexceptionでクラッシュしているようです。
|
3
|
+
ストアからダウンロードして~~android7.0以前の端末で試したり、8.0の端末でUSBデバッグをした際は起動するのですが、ストアからダウンロードして8.0で~~開こうとすると強制終了してしまいます。playConsoleの情報を見る限り起動時データベースを読み込むところでillegalstateexceptionでクラッシュしているようです。
|
4
4
|
USBデバッグだと強制終了しなかったりと何が原因なのかつかめない状態でいます。
|
5
5
|
どんな原因なのか教えていただきたいです。
|
6
6
|
下に起動時のアクティビティを載せておきます。
|
@@ -16,6 +16,7 @@
|
|
16
16
|
saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
|
17
17
|
の行でillegalstateexceptionが発生しているようです。
|
18
18
|
エラーメッセージを追加しました
|
19
|
+
8.0でも起動できる機種起動できない機種があることが分かりました
|
19
20
|
|
20
21
|
java.lang.RuntimeException:
|
21
22
|
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2917)
|
3
エラーメッセージの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,9 +15,33 @@
|
|
15
15
|
更に確認したところ
|
16
16
|
saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
|
17
17
|
の行でillegalstateexceptionが発生しているようです。
|
18
|
+
エラーメッセージを追加しました
|
18
19
|
|
20
|
+
java.lang.RuntimeException:
|
21
|
+
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2917)
|
22
|
+
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2978)
|
23
|
+
at android.app.ActivityThread.-wrap14 (ActivityThread.java)
|
24
|
+
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1628)
|
25
|
+
at android.os.Handler.dispatchMessage (Handler.java:102)
|
26
|
+
at android.os.Looper.loop (Looper.java:154)
|
27
|
+
at android.app.ActivityThread.main (ActivityThread.java:6646)
|
28
|
+
at java.lang.reflect.Method.invoke (Native Method)
|
29
|
+
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1468)
|
30
|
+
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)
|
31
|
+
Caused by: java.lang.IllegalStateException:
|
32
|
+
at android.database.CursorWindow.nativeGetLong (Native Method)
|
33
|
+
at android.database.CursorWindow.getLong (CursorWindow.java:524)
|
34
|
+
at android.database.CursorWindow.getInt (CursorWindow.java:591)
|
35
|
+
at android.database.AbstractWindowedCursor.getInt (AbstractWindowedCursor.java:69)
|
36
|
+
at pakcage.SQLMyWritable.load (SQLMyWritable.kt:59)
|
37
|
+
at pakcage.TitleActivity.loadSaveData (TitleActivity.kt:67)
|
38
|
+
at pakcage.TitleActivity.onCreate (TitleActivity.kt:24)
|
39
|
+
at android.app.Activity.performCreate (Activity.java:6912)
|
40
|
+
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126)
|
41
|
+
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2870)
|
19
42
|
|
20
43
|
|
44
|
+
|
21
45
|
```ここに言語を入力
|
22
46
|
|
23
47
|
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,8 +12,12 @@
|
|
12
12
|
処理が多すぎて強制終了してしまうということなのでしょうか?
|
13
13
|
どのように変更すれば対応できますでしょうか?よろしくお願いします。
|
14
14
|
|
15
|
+
更に確認したところ
|
16
|
+
saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
|
17
|
+
の行でillegalstateexceptionが発生しているようです。
|
15
18
|
|
16
19
|
|
20
|
+
|
17
21
|
```ここに言語を入力
|
18
22
|
|
19
23
|
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,13 @@
|
|
7
7
|
他に必要なものがあれば教えてください。
|
8
8
|
よろしくお願いします。
|
9
9
|
|
10
|
+
追記
|
11
|
+
SQLMyWritableのloadを呼ぶと強制終了してしまうことからinitLoad()として一部に減らしてみたところ強制終了が防げました。
|
12
|
+
処理が多すぎて強制終了してしまうということなのでしょうか?
|
13
|
+
どのように変更すれば対応できますでしょうか?よろしくお願いします。
|
10
14
|
|
15
|
+
|
16
|
+
|
11
17
|
```ここに言語を入力
|
12
18
|
|
13
19
|
|
@@ -19,9 +25,6 @@
|
|
19
25
|
import android.widget.Button
|
20
26
|
import android.widget.EditText
|
21
27
|
import android.widget.Toast
|
22
|
-
import com.google.android.gms.ads.AdRequest
|
23
|
-
import com.google.android.gms.ads.AdView
|
24
|
-
import com.google.android.gms.ads.MobileAds
|
25
28
|
|
26
29
|
class TitleActivity : AppCompatActivity() {
|
27
30
|
|
@@ -36,12 +39,6 @@
|
|
36
39
|
loadSaveData()
|
37
40
|
myBgm = MyBgm(this)
|
38
41
|
this.myBgm.start3()
|
39
|
-
|
40
|
-
|
41
|
-
MobileAds.initialize(this, "id")
|
42
|
-
adView()
|
43
|
-
|
44
|
-
|
45
42
|
}
|
46
43
|
|
47
44
|
//ゲームスタート
|
@@ -56,18 +53,6 @@
|
|
56
53
|
}
|
57
54
|
}
|
58
55
|
|
59
|
-
//名前入力
|
60
|
-
fun decideName(view: View) {
|
61
|
-
val editText = findViewById<EditText>(R.id.nameEditText)
|
62
|
-
if (editText.text.isEmpty()) {
|
63
|
-
Toast.makeText(this, "名前を入力してください", Toast.LENGTH_SHORT).show()
|
64
|
-
} else {
|
65
|
-
saveData.myCharacter.Name = editText.text.toString()
|
66
|
-
dataSave()
|
67
|
-
val event = Event(this, 0, saveData,myBgm)
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
56
|
//セーブ
|
72
57
|
fun dataSave() {
|
73
58
|
val sqlMyWritable = SQLMyWritable(this)
|
@@ -80,36 +65,102 @@
|
|
80
65
|
saveData = sqlMyWritable.load()
|
81
66
|
}
|
82
67
|
|
83
|
-
override fun onResume() {
|
84
|
-
super.onResume()
|
85
|
-
myBgm.start3()//BGM再生
|
86
|
-
if (mAdView != null) {
|
87
|
-
mAdView.resume()
|
88
|
-
|
68
|
+
}
|
69
|
+
```
|
70
|
+
|
71
|
+
```ここに言語を入力
|
72
|
+
|
73
|
+
|
74
|
+
import android.content.ContentValues
|
75
|
+
import android.content.Context
|
76
|
+
import android.database.Cursor
|
77
|
+
|
78
|
+
class SQLMyWritable(val context: Context) {
|
79
|
+
|
80
|
+
fun initLoad(): SaveData {
|
81
|
+
val openHelper = SQLMyOpenHelper(context)
|
82
|
+
val database = openHelper.getWritableDatabase()
|
83
|
+
|
84
|
+
var cursor: Cursor? = null
|
85
|
+
cursor = database.query(
|
86
|
+
SQLMyContract.SaveData.TABLE_NAME,
|
87
|
+
null, null, null, null, null, null, null
|
88
|
+
)
|
89
|
+
val saveData = SaveData()
|
90
|
+
|
91
|
+
cursor.moveToFirst()
|
92
|
+
|
93
|
+
saveData.myCharacter.Name = cursor.getString(cursor.getColumnIndex(SQLMyContract.SaveData.MY_NAME))
|
94
|
+
saveData.eventData.initEvent = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.INITEVENT)))
|
95
|
+
|
96
|
+
return saveData
|
89
97
|
}
|
90
98
|
|
91
|
-
|
99
|
+
//読み込み
|
92
|
-
|
100
|
+
fun load(): SaveData {
|
101
|
+
val openHelper = SQLMyOpenHelper(context)
|
102
|
+
val database = openHelper.getWritableDatabase()
|
103
|
+
|
104
|
+
var cursor: Cursor? = null
|
105
|
+
cursor = database.query(
|
106
|
+
SQLMyContract.SaveData.TABLE_NAME,
|
107
|
+
null, null, null, null, null, null, null
|
108
|
+
)
|
109
|
+
val saveData = SaveData()
|
110
|
+
|
111
|
+
cursor.moveToFirst()
|
112
|
+
|
113
|
+
saveData.myCharacter.Name = cursor.getString(cursor.getColumnIndex(SQLMyContract.SaveData.MY_NAME))
|
114
|
+
saveData.myCharacter.HP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_HP))
|
115
|
+
saveData.myCharacter.MaxHP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MAX_HP))
|
116
|
+
saveData.myCharacter.MP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MP))
|
117
|
+
saveData.myCharacter.MaxMP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_MAX_MP))
|
118
|
+
saveData.myCharacter.STR = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_STR))
|
119
|
+
saveData.myCharacter.DEF = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_DEF))
|
120
|
+
saveData.myCharacter.AGI = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_AGI))
|
121
|
+
saveData.myCharacter.INT = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_INT))
|
122
|
+
saveData.myCharacter.EXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_EXP))
|
123
|
+
saveData.myCharacter.theEXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_THE_EXP))
|
124
|
+
saveData.myCharacter.EXP_BONUS = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MY_EXP_BONUS))
|
125
|
+
|
126
|
+
saveData.eventData.boss1 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS1)))
|
127
|
+
saveData.eventData.boss2 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS2)))
|
128
|
+
saveData.eventData.boss3 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS3)))
|
129
|
+
saveData.eventData.boss4 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS4)))
|
130
|
+
saveData.eventData.boss5 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS5)))
|
131
|
+
saveData.eventData.boss6 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS6)))
|
132
|
+
saveData.eventData.boss7 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS7)))
|
133
|
+
saveData.eventData.boss8 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS8)))
|
134
|
+
saveData.eventData.boss9 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS9)))
|
135
|
+
saveData.eventData.boss10 = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.BOSS10)))
|
136
|
+
saveData.eventData.initEvent = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.INITEVENT)))
|
137
|
+
|
138
|
+
saveData.floor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.NOW_FLOOR))
|
139
|
+
saveData.isBattle = returnBoolean(cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.IS_BATTLE)))
|
140
|
+
saveData.enemyHP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ENEMY_HP))
|
141
|
+
saveData.enemyNo = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ENEMY_NO))
|
142
|
+
|
143
|
+
saveData.maxFloor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.MAX_FLOOR))
|
144
|
+
saveData.startFloor = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.START_FLOOR))
|
145
|
+
|
146
|
+
saveData.winTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.WIN_TIMES))
|
147
|
+
saveData.escapeTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.ESCAPE_TIMES))
|
148
|
+
saveData.gameOverTimes = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.GAME_OVER_TIMES))
|
149
|
+
|
150
|
+
saveData.EXP = cursor.getInt(cursor.getColumnIndex(SQLMyContract.SaveData.EXP))
|
93
|
-
|
151
|
+
database.close()
|
94
|
-
}
|
95
|
-
|
152
|
+
cursor.close()
|
96
|
-
|
153
|
+
return saveData
|
97
154
|
}
|
98
155
|
|
99
|
-
|
156
|
+
fun returnBoolean(i: Int): Boolean {
|
157
|
+
var b = false
|
158
|
+
when (i) {
|
100
|
-
|
159
|
+
0 -> b = false
|
101
|
-
|
160
|
+
1 -> b = true
|
102
161
|
}
|
103
|
-
|
162
|
+
return b
|
104
163
|
}
|
105
164
|
|
106
|
-
|
107
|
-
//広告
|
108
|
-
private fun adView(){
|
109
|
-
mAdView = findViewById(R.id.adView)
|
110
|
-
val adRequest = AdRequest.Builder().build()
|
111
|
-
mAdView.loadAd(adRequest)
|
112
|
-
}
|
113
|
-
|
114
165
|
}
|
115
166
|
```
|