작성
·
340
0
storage에 업로드하는 강의까지 아무 오류없이 로그인도 잘되고 잘됐습니다.
근데 이번 강의를 모두 작성한 후 로그인시 화면이 튕깁니다.
코드에 오류는 전혀 없고 3일동안 프로젝트랑 파이어베이스랑 전부 다 5번 지우고 다시 똑같이 따라써서 한글자도 하나의 설정도 틀린 것이 없습니다. 또한 하울님의 github 코드를 복붙해도 완전히 똑같은 오류가 납니다. Migrate to AndroidX , clean, rebuild, restart 백번했습니다.
MainActivity.kt에 Oncreate에서 상세화면 페이지를 부르는 이 코드를 지우면 로그인을 해도 화면이 튕기지 않습니다.
bottom_navigation.selectedItemId = R.id.action_home
Run 창에
E/AndroidRuntime: FATAL EXCEPTION: grpc-default-executor-0
Process: com.example.jbstagram_try1, PID: 30258
java.lang.AssertionError
at io.grpc.internal.DnsNameResolver.getResourceResolver(DnsNameResolver.java:536)
at io.grpc.internal.DnsNameResolver.access$500(DnsNameResolver.java:60)
at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:211)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
이 오류가 뜨면서 로그인시 메인화면이 뜨자마자 튕기며
제 DetailViewFragment.kt의 코드는 이렇습니다.
package com.example.jbstagram_try1.navigation
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.jbstagram_try1.R
import com.example.jbstagram_try1.navigation.model.ContentDTO
import com.google.firebase.firestore.FirebaseFirestore
import kotlinx.android.synthetic.main.item_detail.view.*
import kotlinx.android.synthetic.main.fragment_detail.view.*
//
class DetailViewFragment : Fragment(){
var firestore : FirebaseFirestore? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
var view = LayoutInflater.from(activity).inflate(R.layout.fragment_detail,container,false)
firestore = FirebaseFirestore.getInstance()
view.detailviewfragment_recyclerview.adapter = DetailViewRecyclerViewAdapter()
view.detailviewfragment_recyclerview.layoutManager = LinearLayoutManager(activity)
return view
}
inner class DetailViewRecyclerViewAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(){
var contentDTOs : ArrayList<ContentDTO> = arrayListOf()
var contentUidList : ArrayList<String> = arrayListOf()
init {
firestore?.collection("images")?.orderBy("timestamp")?.addSnapshotListener { querySnapshot, firebaseFirestoreException ->
contentDTOs.clear()
contentUidList.clear()
for (snapshot in querySnapshot!!.documents){
var item = snapshot.toObject(ContentDTO::class.java)
contentDTOs.add(item!!)
contentUidList.add(snapshot.id)
}
notifyDataSetChanged()
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
var view = LayoutInflater.from(parent.context).inflate(R.layout.item_detail,parent,false)
return CustomViewHolder(view)
}
inner class CustomViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
var viewholder = (holder as CustomViewHolder).itemView
viewholder.detailviewitem_profile_textview.text = contentDTOs!![position].userId
Glide.with(holder.itemView.context).load(contentDTOs!![position].imageUrl).into(viewholder.detailviewitem_imageview_content)
viewholder.detailviewitem_explain_textview.text = contentDTOs!![position].explain
viewholder.detailviewitem_favoritecounter_textview.text = "Likes" + contentDTOs!![position].favoriteCount
Glide.with(holder.itemView.context).load(contentDTOs!![position].imageUrl).into(viewholder.detailviewitem_profile_image)
}
override fun getItemCount(): Int {
return contentDTOs.size
}
}
}
이건 MainActivity.kt 코드입니다.
package com.example.jbstagram_try1
import android.content.Intent
import android.content.pm.PackageManager
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.example.jbstagram_try1.navigation.*
import com.example.jbstagram_try1.R
import com.example.jbstagram_try1.navigation.*
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.android.synthetic.main.activity_main.*
import java.util.jar.Manifest
class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener {
override fun onNavigationItemSelected(p0: MenuItem): Boolean {
when (p0.itemId) {
R.id.action_home -> {
var detailViewFragment = DetailViewFragment()
supportFragmentManager.beginTransaction()
.replace(R.id.main_content, detailViewFragment).commit()
return true
}
R.id.action_search -> {
var gridFragment = GridFragment()
supportFragmentManager.beginTransaction().replace(R.id.main_content, gridFragment)
.commit()
return true
}
R.id.action_add_photo -> {
if (ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
) {
startActivity(Intent(this, AddPhotoActivity::class.java))
}
return true
}
R.id.action_favorite_alarm -> {
var alarmFragment = AlarmFragment()
supportFragmentManager.beginTransaction().replace(R.id.main_content, alarmFragment)
.commit()
return true
}
R.id.action_account -> {
var userFragment = UserFragment()
supportFragmentManager.beginTransaction().replace(R.id.main_content, userFragment)
.commit()
return true
}
}
return false
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
bottom_navigation.setOnNavigationItemSelectedListener(this)
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE), 1)
bottom_navigation.selectedItemId = R.id.action_home
}
}
답변 3
0
0
->Run에서 코드를 실행할 때 한번 뜹니다.
The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
->build에서 노란경고로 뜹니다.
이거말고는 전혀없습니다!
0