Android Studio Не удалось найти явный класс активности, хотя класс существует

Я застрял с кодом для школы. Я следил за учебником и чувствую, что у меня 100% то же самое (проверено несколько раз). Но все равно получаю ошибку. Android Studio не показывает никаких ошибок.

Большое спасибо за любую помощь!

Я получаю следующую ошибку:

   --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.ecosense, PID: 4840
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.ecosense/com.example.ecosense.ResultActivity}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
        at android.app.Activity.startActivityForResult(Activity.java:4586)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
        at android.app.Activity.startActivityForResult(Activity.java:4544)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
        at com.example.ecosense.QuestionActivity.finishGame(QuestionActivity.kt:318)
        at com.example.ecosense.QuestionActivity.access$finishGame(QuestionActivity.kt:44)
        at com.example.ecosense.QuestionActivity$onOptionsItemSelected$2.onClick(QuestionActivity.kt:375)
        at com.afollestad.materialdialogs.MaterialDialog.onClick(MaterialDialog.java:367)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

А это мой класс QuestionActivity.

package com.example.ecosense

import android.app.Activity
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.os.CountDownTimer
import android.support.constraint.ConstraintLayout
import android.support.design.widget.Snackbar
import android.support.design.widget.NavigationView
import android.support.v4.content.LocalBroadcastManager
import android.support.v4.view.GravityCompat
import android.support.v4.view.ViewPager
import android.support.v4.widget.DrawerLayout
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.Gravity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.Button
import android.widget.TextView
import com.example.ecosense.Adapter.GridAnswerAdapter
import com.example.ecosense.Adapter.MyFragmentAdapter
import com.example.ecosense.Adapter.QuestionListHelperAdapter
import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog
import com.example.ecosense.Common.Common
import com.example.ecosense.Common.SpacesItemDecoration
import com.example.ecosense.DBHelper.DBHelper
import com.example.ecosense.Model.CurrentQuestion
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_question.*
import kotlinx.android.synthetic.main.app_bar_question.*
import kotlinx.android.synthetic.main.content_question.*
import org.w3c.dom.Text
import java.lang.StringBuilder
import java.util.concurrent.TimeUnit

class QuestionActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {

    val CODE_GET_RESULT = 9999

    lateinit var countDownTimer: CountDownTimer

    var time_play = Common.TOTAL_TIME

    var isAnswerModeView = false

    lateinit var adapter: GridAnswerAdapter

    lateinit var questionHelperAdapter: QuestionListHelperAdapter

    lateinit var txt_wrong_answer: TextView

    internal var goToQuestionNum: BroadcastReceiver = object : BroadcastReceiver() {
        override fun onReceive(context: Context?, intent: Intent?) {
            if (intent!!.action!!.toString() == Common.KEY_GO_TO_QUESTION) {
                val question = intent!!.getIntExtra(Common.KEY_GO_TO_QUESTION, -1)
                if (question != -1)
                    view_pager.currentItem = question

                drawer_layout.closeDrawer(Gravity.LEFT)
            }
        }

    }

    override fun onDestroy() {
        LocalBroadcastManager.getInstance(this).unregisterReceiver(goToQuestionNum)
        if (countDownTimer != null)
            countDownTimer!!.cancel()
        if (Common.fragmentList != null)
            Common.fragmentList.clear()
        if (Common.answerSheetList != null)
            Common.answerSheetList.clear()
        super.onDestroy()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_question)
        setSupportActionBar(toolbar)


        LocalBroadcastManager.getInstance(this)
            .registerReceiver(goToQuestionNum, IntentFilter(Common.KEY_GO_TO_QUESTION))

        val toggle = ActionBarDrawerToggle(
            this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
        )
        drawer_layout.addDrawerListener(toggle)
        toggle.syncState()

        nav_view.setNavigationItemSelectedListener(this)

        val recycler_helper_answer_sheet =
            nav_view.getHeaderView(0).findViewById<View>(R.id.answer_sheet) as RecyclerView
        recycler_helper_answer_sheet.layoutManager = GridLayoutManager(this, 3)
        recycler_helper_answer_sheet.setHasFixedSize(true)
        recycler_helper_answer_sheet.addItemDecoration(SpacesItemDecoration(2))

        val btn_done = nav_view.getHeaderView(0).findViewById<View>(R.id.btn_done) as Button
        btn_done.setOnClickListener {
            if (!isAnswerModeView)
            {
                MaterialStyledDialog.Builder(this@QuestionActivity)
                    .setTitle("Finish?")
                    .setDescription("Do you really want to finish?")
                    .setIcon(R.drawable.ic_mood_white_24dp)
                    .setNegativeText("No")
                    .onNegative { dialog, which -> dialog.dismiss() }
                    .setPositiveText("Yes")
                    .onPositive { dialog, which -> finishGame()
                     drawer_layout.closeDrawer(Gravity.LEFT)}
                    .show()

            }
            else {
                finishGame()

            }
        }

        //Get Question base on Category
        genQuestion()

        if (Common.questionList.size > 0) {
            //Show Timer, Right Answer text view
            txt_timer.visibility = View.VISIBLE
            txt_right_answer.visibility = View.VISIBLE

            countTimer()

            //Gen item for grid_answer
            genItems()
            grid_answer.setHasFixedSize(true)
            if (Common.questionList.size > 0)
                grid_answer.layoutManager = GridLayoutManager(
                    this,
                    if (Common.questionList.size > 5) Common.questionList.size / 2 else Common.questionList.size
                )
            adapter = GridAnswerAdapter(this, Common.answerSheetList)


            grid_answer.adapter = adapter

            //Gen fragment list
            genFragmentList()

            val fragmentAdapter = MyFragmentAdapter(supportFragmentManager, this, Common.fragmentList)
            view_pager.offscreenPageLimit = Common.questionList.size
            view_pager.adapter = fragmentAdapter // Bind question to View Pager

            sliding_tabs.setupWithViewPager(view_pager)

            //Event
            view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {

                val SCROLLING_RIGHT = 0
                val SCROLLING_LEFT = 1
                val SCROLLING_UNDETERMINED = 2

                var currentScrollDirection = SCROLLING_UNDETERMINED

                private val isScrollDirectionUndetermined: Boolean
                    get() = currentScrollDirection == SCROLLING_UNDETERMINED
                private val isScrollDirectionRight: Boolean
                    get() = currentScrollDirection == SCROLLING_RIGHT
                private val isScrollDirectionLeft: Boolean
                    get() = currentScrollDirection == SCROLLING_LEFT


                private fun setScrollingDirection(positionOffset: Float) {
                    if (1 - positionOffset >= 0.5)
                        this.currentScrollDirection = SCROLLING_RIGHT
                    else if (1 - positionOffset <= 0.5)
                        this.currentScrollDirection = SCROLLING_LEFT


                }

                override fun onPageScrollStateChanged(p0: Int) {
                    if (p0 == ViewPager.SCROLL_STATE_IDLE)
                        this.currentScrollDirection = SCROLLING_UNDETERMINED
                }

                override fun onPageScrolled(p0: Int, p1: Float, p2: Int) {
                    if (isScrollDirectionUndetermined)
                        setScrollingDirection(p1)
                }

                override fun onPageSelected(p0: Int) {

                    val questionFragment: QuestionFragment
                    var position = 0
                    if (p0 > 0) {
                        if (isScrollDirectionRight) {
                            questionFragment = Common.fragmentList[p0 - 1]
                            position = p0 - 1
                        } else if (isScrollDirectionLeft) {
                            questionFragment = Common.fragmentList[p0 + 1]
                            position = p0 + 1
                        } else {
                            questionFragment = Common.fragmentList[p0]
                        }
                    } else {
                        questionFragment = Common.fragmentList[0]
                        position = 0
                    }


                    if (Common.answerSheetList[position].type == Common.ANSWER_TYPE.NO_ANSWER) {
                        // If you want to show correct answer, enable it
                        val question_state = questionFragment.selectedAnswer()
                        Common.answerSheetList[position] = question_state
                        adapter.notifyDataSetChanged()
                        questionHelperAdapter.notifyDataSetChanged()

                        countCorrectAnswer()

                        txt_right_answer.text = ("${Common.right_answer_count} / ${Common.questionList.size}")
                        txt_wrong_answer.text = "${Common.wrong_answer_count}"

                        if (question_state.type != Common.ANSWER_TYPE.NO_ANSWER) {
                            questionFragment.showCorrectAnswer()
                            questionFragment.disableAnswer()
                        }
                    }
                }

            })


            txt_right_answer.text = "${Common.right_answer_count}/${Common.questionList.size}"
            questionHelperAdapter = QuestionListHelperAdapter(this, Common.answerSheetList)
            recycler_helper_answer_sheet.adapter = questionHelperAdapter
        }
    }

    private fun countCorrectAnswer() {
        Common.right_answer_count = 0 // Reset
        Common.wrong_answer_count = 0

        for (item in Common.answerSheetList)
            if (item.type == Common.ANSWER_TYPE.RIGHT_ANSWER)
                Common.right_answer_count++
            else if (item.type == Common.ANSWER_TYPE.WRONG_ANSWER)
                Common.wrong_answer_count++
    }

    private fun genFragmentList() {
        for (i in Common.questionList.indices) {
            val bundle = Bundle()
            bundle.putInt("index", i)
            val fragment = QuestionFragment()
            fragment.arguments = bundle

            Common.fragmentList.add(fragment)
        }
    }

    private fun genItems() {
        for (i in Common.questionList.indices)
            Common.answerSheetList.add(CurrentQuestion(i, Common.ANSWER_TYPE.NO_ANSWER)) // No answer for all questions
    }

    private fun countTimer() {
        countDownTimer = object : CountDownTimer(Common.TOTAL_TIME.toLong(), 1000) {
            override fun onFinish() {
                finishGame()
            }

            override fun onTick(interval: Long) {
                txt_timer.text = (java.lang.String.format(
                    "%02d:%02d",
                    TimeUnit.MILLISECONDS.toMinutes(interval),
                    TimeUnit.MILLISECONDS.toSeconds(interval) - TimeUnit.MINUTES.toSeconds(
                        TimeUnit.MILLISECONDS.toMinutes(
                            interval
                        )
                    )
                ))
                time_play -= 1000
            }

        }.start()
    }

    private fun finishGame() {
        val position = view_pager.currentItem
        val questionFragment = Common.fragmentList[position]

        val question_state = questionFragment.selectedAnswer()
        Common.answerSheetList[position] = question_state
        adapter.notifyDataSetChanged()
        questionHelperAdapter.notifyDataSetChanged()

        countCorrectAnswer()

        txt_right_answer.text = ("${Common.right_answer_count} / ${Common.questionList.size}")
        txt_wrong_answer.text = "${Common.wrong_answer_count}"

        if (question_state.type != Common.ANSWER_TYPE.NO_ANSWER) {
            questionFragment.showCorrectAnswer()
            questionFragment.disableAnswer()
        }

        val intent = Intent(this@QuestionActivity, ResultActivity::class.java)
        Common.timer = Common.TOTAL_TIME - time_play
        Common.no_answer_count = Common.questionList.size - (Common.right_answer_count + Common.wrong_answer_count)
        Common.data_question = StringBuilder(Gson().toJson(Common.answerSheetList))

        startActivityForResult(intent, CODE_GET_RESULT)

    }

    private fun genQuestion() {
        Common.questionList = DBHelper.getInstance(this)
            .getQuestionByCategory(Common.selectedCategory!!.id)

        if (Common.questionList.size == 0) {
            MaterialStyledDialog.Builder(this)
                .setTitle("Oppps!")
                .setIcon(R.drawable.ic_sentiment_very_dissatisfied_black_24dp)
                .setDescription("We don't have any question in this ${Common.selectedCategory!!.name} category")
                .setPositiveText("OK")
                .onPositive { dialog, which ->
                    dialog.dismiss()
                    finish()
                }.show()
        }
    }

    override fun onBackPressed() {
        val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
        if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
            drawerLayout.closeDrawer(GravityCompat.START)
        } else {
            this.finish() // Close this activity when click on back button
            super.onBackPressed()
        }
    }

    override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
        val item = menu!!.findItem(R.id.menu_wrong_answer)
        val layout = item.actionView as ConstraintLayout
        txt_wrong_answer = layout.findViewById(R.id.txt_wrong_answer) as TextView
        txt_wrong_answer.text = 0.toString()
        return true
    }

    override fun onCreateOptionsMenu(menu: Menu): Boolean {
        // Inflate the menu; this adds items to the action bar if it is present.
        menuInflater.inflate(R.menu.question, menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            R.id.menu_done -> {
                if (!isAnswerModeView) {
                    MaterialStyledDialog.Builder(this@QuestionActivity)
                        .setTitle("Finish?")
                        .setDescription("Do you really want to finish?")
                        .setIcon(R.drawable.ic_mood_white_24dp)
                        .setNegativeText("No")
                        .onNegative { dialog, which -> dialog.dismiss() }
                        .setPositiveText("Yes")
                        .onPositive { dialog, which ->
                            finishGame()
                            drawer_layout.closeDrawer(Gravity.LEFT)
                        }.show()

                } else {
                    finishGame()
                }
            }
        }
        return true

    }

    override fun onNavigationItemSelected(item: MenuItem): Boolean {
        // Handle navigation view item clicks here.
        when (item.itemId) {
            R.id.nav_home -> {
                // Handle the camera action
            }
            R.id.nav_gallery -> {

            }
            R.id.nav_slideshow -> {

            }
            R.id.nav_tools -> {

            }
            R.id.nav_share -> {

            }
            R.id.nav_send -> {

            }
        }
        val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
        drawerLayout.closeDrawer(GravityCompat.START)
        return true
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == CODE_GET_RESULT)
        {
            if (resultCode == Activity.RESULT_OK)
            {
                val action = data!!.getStringExtra("action")
                if (action == null || TextUtils.isEmpty(action))
                {
                    val questionIndex = data.getIntExtra(Common.KEY_BACK_FROM_RESULT, -1)
                    view_pager.currentItem = questionIndex

                    isAnswerModeView = true
                    countDownTimer!!.cancel()

                    txt_wrong_answer.visibility = View.GONE
                    txt_right_answer.visibility = View.GONE
                    txt_timer.visibility = View.GONE
                }
                else
                {
                    if (action.equals("doquizagain"))
                        {
                            view_pager.currentItem = 0
                            isAnswerModeView = false

                        txt_wrong_answer.visibility = View.VISIBLE
                        txt_right_answer.visibility = View.VISIBLE
                        txt_timer.visibility = View.VISIBLE

                        for (i in Common.fragmentList.indices) {
                            Common.fragmentList[i].resetQuestion()
                        }

                        for (i in Common.answerSheetList.indices)
                            Common.answerSheetList[i].type = Common.ANSWER_TYPE.NO_ANSWER

                        adapter.notifyDataSetChanged()
                        questionHelperAdapter.notifyDataSetChanged()

                        countTimer()

                    } else if (action.equals("viewanswer"))
                    {
                        view_pager.currentItem = 0
                        isAnswerModeView = true
                        countDownTimer!!.cancel()

                        txt_wrong_answer.visibility = View.GONE
                        txt_right_answer.visibility = View.GONE
                        txt_timer.visibility = View.GONE

                        for (i in Common.fragmentList.indices)
                        {
                            Common.fragmentList[i].showCorrectAnswer()
                            Common.fragmentList[i].disableAnswer()
                        }
                        }
                    }
                }
            }
    }
}

Мой класс ResultActivity:

package com.example.ecosense

import android.app.Activity
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.content.LocalBroadcastManager
import android.support.v7.widget.GridLayoutManager
import android.view.Gravity
import android.view.Menu
import android.view.MenuItem
import com.example.ecosense.Adapter.ResultGridAdapter
import com.example.ecosense.Common.Common
import com.example.ecosense.Common.SpacesItemDecoration
import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog
import kotlinx.android.synthetic.main.activity_question.*
import kotlinx.android.synthetic.main.activity_result.*
import kotlinx.android.synthetic.main.activity_result.txt_right_answer
import kotlinx.android.synthetic.main.content_question.*
import java.util.concurrent.TimeUnit

class ResultActivity : AppCompatActivity() {

    internal var backToQuestion:BroadcastReceiver = object:BroadcastReceiver(){
        override fun onReceive(context: Context?, intent: Intent?) {
            if (intent!!.action!!.toString() == Common.KEY_BACK_FROM_RESULT)
            {
                val questionIndex = intent.getIntExtra(Common.KEY_BACK_FROM_RESULT,-1)
                goBackActivityWithQuestionIndex(questionIndex)
            }
        }

    }

    private fun goBackActivityWithQuestionIndex(questionIndex: Int) {
        val returnIntent = Intent()
        returnIntent.putExtra(Common.KEY_BACK_FROM_RESULT,questionIndex)
        setResult(Activity.RESULT_OK,returnIntent)
        finish()

    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.menu_result,menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        when(item!!.itemId)
        {
            R.id.menu_do_quiz_again -> doQuizAgain()
            R.id.menu_view_answer -> viewAnswer()
            android.R.id.home -> {
                val intent = Intent(applicationContext,CategoryActivity::class.java)
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                startActivity(intent) // Go back to category when click on back arrow in result activity
            }
        }
        return true
    }

    private fun viewAnswer() {
        val returnIntent = Intent()
        returnIntent.putExtra("action","viewanswer")
        setResult(Activity.RESULT_OK,returnIntent)
        finish()
    }

    private fun doQuizAgain() {

        MaterialStyledDialog.Builder(this@ResultActivity)
            .setTitle("Do quiz again?")
            .setDescription("Do you really want to delete this data?")
            .setIcon(R.drawable.ic_mood_white_24dp)
            .setNegativeText("No")
            .onNegative { dialog, which -> dialog.dismiss() }
            .setPositiveText("Yes")
            .onPositive { dialog, which ->

                val returnIntent = Intent()
                returnIntent.putExtra("action","doquizagain")
                setResult(Activity.RESULT_OK,returnIntent)
                finish()
            }
            .show()
    }

    override fun onDestroy() {
        LocalBroadcastManager.getInstance(this@ResultActivity)
            .unregisterReceiver(backToQuestion)
        super.onDestroy()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_result)

        LocalBroadcastManager.getInstance(this@ResultActivity)
            .registerReceiver(backToQuestion, IntentFilter(Common.KEY_BACK_FROM_RESULT))

        toolbar.title = "Result"
        setSupportActionBar(toolbar)

        supportActionBar!!.setDisplayHomeAsUpEnabled(true)
        supportActionBar!!.setDisplayShowHomeEnabled(true)

        //
        txt_timer.text = (java.lang.String.format(
            "%02d:%02d",
            TimeUnit.MILLISECONDS.toMinutes(Common.timer.toLong()),
            TimeUnit.MILLISECONDS.toSeconds(Common.timer.toLong()) - TimeUnit.MINUTES.toSeconds(
                TimeUnit.MILLISECONDS.toMinutes(
                    Common.timer.toLong()
                )
            )
        ))
        txt_right_answer.text = "${Common.right_answer_count}/${Common.questionList.size}"

        btn_filter_total.text = "${Common.questionList.size}"
        btn_filter_total.text = "${Common.right_answer_count}"
        btn_filter_total.text = "${Common.wrong_answer_count}"
        btn_filter_total.text = "${Common.no_answer_count}"

        val percent = Common.right_answer_count*100/Common.questionList.size
        if (percent > 80)
            txt_result.text = "Excellent!"
        else if (percent > 65)
            txt_result.text = "Good!"
        else if (percent > 50)
            txt_result.text = "Fair!"
        else
            txt_result.text = "Bad!"

        // Event Button
        btn_filter_total.setOnClickListener{
            val adapter = ResultGridAdapter(this,Common.answerSheetList)
            recycler_result.adapter = adapter
        }

        btn_filter_no_answer.setOnClickListener{
            Common.answerSheetListFiltered.clear()

            for (currentQuestion in Common.answerSheetList)
                if (currentQuestion.type == Common.ANSWER_TYPE.NO_ANSWER)
                    Common.answerSheetListFiltered.add(currentQuestion)
            val adapter = ResultGridAdapter(this,Common.answerSheetListFiltered)
            recycler_result.adapter = adapter
        }

        btn_filter_wrong.setOnClickListener{
            Common.answerSheetListFiltered.clear()

            for (currentQuestion in Common.answerSheetList)
                if (currentQuestion.type == Common.ANSWER_TYPE.WRONG_ANSWER)
                    Common.answerSheetListFiltered.add(currentQuestion)
            val adapter = ResultGridAdapter(this,Common.answerSheetListFiltered)
            recycler_result.adapter = adapter
        }

        btn_filter_right.setOnClickListener{
            Common.answerSheetListFiltered.clear()

            for (currentQuestion in Common.answerSheetList)
                if (currentQuestion.type == Common.ANSWER_TYPE.RIGHT_ANSWER)
                    Common.answerSheetListFiltered.add(currentQuestion)
            val adapter = ResultGridAdapter(this,Common.answerSheetListFiltered)
            recycler_result.adapter = adapter
        }


        // Set Adapter
        val adapter = ResultGridAdapter(this,Common.answerSheetList)
        recycler_result.setHasFixedSize(true)
        recycler_result.layoutManager = GridLayoutManager(this,4)
        recycler_result.addItemDecoration(SpacesItemDecoration(4))
        recycler_result.adapter = adapter


    }
}

Вы добавили свою активность в свой манифест?

A Farmanbar 26.05.2019 11:48

Да хотя в туте этого не было.. Но добавил и все равно ошибка...

viktor 26.05.2019 11:58

поместите сюда свой манифест

A Farmanbar 26.05.2019 11:59

Здесь: ufile.io/wf2jcrjk Извините, осталось недостаточно символов, мне пришлось загрузить .txt

viktor 26.05.2019 12:04

И весь проект: ufile.io/kr8f25pu

viktor 26.05.2019 12:07

я запускаю ваш проект, и не было никаких ошибок, и все хорошо. попробуйте сделать недействительным ваш ide или обновленные плагины kotlin.

A Farmanbar 26.05.2019 16:04

Ну да, ошибка возникает только при отладке. Сама сборка без ошибок. Приложение запускается без проблем. Вы получите сообщение об ошибке, когда вы нажмете на завершение игры, хотя .....

viktor 26.05.2019 16:52

Вы знаете, как это исправить? Я вижу эту ошибку, которая является исключением нулевого указателя.

A Farmanbar 26.05.2019 16:57

Нет, я не знаю...

viktor 26.05.2019 16:59

Ржу не могу. Хорошо, я напишу вам, как это исправить.

A Farmanbar 26.05.2019 17:03

Хорошо, спасибо!

viktor 26.05.2019 17:50
2
11
432
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

У вас есть 3 действия, но то, что вы показываете, кстати, имеет 2 действия, если есть другое действие, вы должны добавить его в манифест. У вас есть эти действия

ResultActivity
CategoryActivity
QuestionActivity

В вашем манифесте их 2

CategoryActivity
QuestionActivity

правильный манифест

<?xml version = "1.0" encoding = "utf-8"?>
<manifest xmlns:android = "http://schemas.android.com/apk/res/android"
          package = "com.example.ecosense">

    <uses-permission android:name = "android.permission.INTERNET"/>

    <application
            android:allowBackup = "true"
            android:icon = "@mipmap/ic_launcher"
            android:label = "@string/app_name"
            android:roundIcon = "@mipmap/ic_launcher_round"
            android:supportsRtl = "true"
            android:theme = "@style/AppTheme">
        <activity android:name = ".ResultActivity"
                  android:label = "activity_result">
        </activity>
        <activity
                android:name = ".QuestionActivity"
                android:label = "title_activity_question">
        </activity>
        <activity android:name = ".CategoryActivity">
            <intent-filter>
                <action android:name = "android.intent.action.MAIN"/>
                <category android:name = "android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

Хм, ну у меня есть 3 мероприятия. CategoryActivity — это моя активность запуска. Я загрузил весь проект для облегчения понимания ... спасибо за вашу помощь, очень ценю это!

viktor 26.05.2019 12:24

В вашем манифесте есть 2x ResultActivity. Я удалил первый и пробовал только с: <activity android:name = ".ResultActivity" android:theme = "@style/AppTheme.NoActionBar"> </activity> Все еще ошибка...

viktor 26.05.2019 12:30

Я почистил и пересобрал проект, все равно ничего.. Я думаю, что что-то не так с QuestionActivity в приватной забаве finishGame()... Но я не уверен.. Отладка показывает мне: at com.example.ecosense.QuestionActivity.finishGame (QuestionAct‌​ivity.kt:318) в com.example.ecosense.QuestionActivity.access$finishGame(Ques‌​tionActivity.kt:44) в com.example.ecosense.QuestionActivity$onOptionsItemSelected$‌​2.onClick(QuestionActivity .кт:375)

viktor 26.05.2019 12:46

@viktor, зайдите в конфигурацию приложения и посмотрите, какая у вас активность по умолчанию, и убедитесь, что ваша активность по умолчанию или активность во время обеда верны.

A Farmanbar 26.05.2019 13:01

Это. Начну с категорий. Тогда я могу нажать на них и играть. Когда я нажимаю закончить игру, она вылетает...

viktor 26.05.2019 13:02

Ну я точно не знаю. Android Studio дает несколько строк, которые я прокомментировал выше, но я не могу найти там никаких ошибок... Может быть, будет проще, если вы попытаетесь быстро импортировать проект, он очень маленький.. Вы должны увидеть его намного больше ясно тогда, спасибо!

viktor 26.05.2019 13:14

Не работает. Будет ли он работать для вас, если вы его измените?

viktor 26.05.2019 13:53

Давайте продолжить обсуждение в чате.

A Farmanbar 26.05.2019 13:54
Ответ принят как подходящий

Итак, я нашел ошибку. Она была в следующем коде. Я использовал txt_timer вместо txt_time, что привело к неправильной ссылке на макет...

        txt_timer.text = (java.lang.String.format(
            "%02d:%02d",
            TimeUnit.MILLISECONDS.toMinutes(Common.timer.toLong()),
            TimeUnit.MILLISECONDS.toSeconds(Common.timer.toLong()) - TimeUnit.MINUTES.toSeconds(
                TimeUnit.MILLISECONDS.toMinutes(
                    Common.timer.toLong()
                )
            )
        ))

Правильный код:

        txt_time.text = (java.lang.String.format(
            "%02d:%02d",
            TimeUnit.MILLISECONDS.toMinutes(Common.timer.toLong()),
            TimeUnit.MILLISECONDS.toSeconds(Common.timer.toLong()) - TimeUnit.MINUTES.toSeconds(
                TimeUnit.MILLISECONDS.toMinutes(
                    Common.timer.toLong()
                )
            )
        ))

да. это правильно. извините, я был занят, и я не мог исправить следующую ошибку.

A Farmanbar 28.05.2019 00:53

Другие вопросы по теме