• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

자바코드 코틀린으로 바꾸고 영상에 나온방법으로 진행하였습니다만…

19.01.29 17:01 작성 조회수 123

1

Unable to find method 'org.gradle.api.artifacts.dsl.DependencyHandler.getAttributesSchema()Lorg/gradle/api/attributes/AttributesSchema;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

라는 오류만 뿌리고 빌드가 되지 않습니다.
클린 프로젝트도 안되네요...

답변 1

답변을 작성해보세요.

0

'''

package w.myapplication

//각각 동작이 실행될때마다 로그를 찍습니다. 로그켓에서 확인하시면 됩니다.

import android.content.Intent

import android.support.v7.app.AppCompatActivity

import android.os.Bundle

import android.util.Log

import android.view.View

import android.widget.Button

import android.widget.EditText

import android.widget.TextView

import android.widget.Toast

import java.util.Random

class MainActivity : AppCompatActivity() {

internal var ran = Random()

internal var use: EditText

internal var user = -1

internal var game = true

internal var f: Int = 0

internal var f_dump: Int = 0

internal var s: Int = 0

internal var s_dump: Int = 0

internal var t: Int = 0

internal var s_dump2: Int = 0

internal var pc = 1

internal var uf: Int = 0

internal var uf_dump: Int = 0

internal var us: Int = 0

internal var us_dump: Int = 0

internal var ut: Int = 0

internal var us_dump2: Int = 0

internal var count = 0

internal var str = 0

internal var bal = 0

internal var a = 0

internal var b = 0

internal var tvs: String

internal var tvb: String

internal var start: Button

internal var play: Button

internal var tv: TextView

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

setContentView(R.layout.activity_main)

Toast.makeText(this, "NEWGAME 버튼을 누른뒤 진행하여주세요!", Toast.LENGTH_SHORT).show()

start = findViewById(R.id.button) as Button

use = findViewById(R.id.editText) as EditText

tv = findViewById(R.id.textView) as TextView

start.setOnClickListener {

//일부조건을 충족하지 않아 게임시작되지 않음

if (game == false) {

Toast.makeText(this@MainActivity, "아직 게임이 진행중입니다!", Toast.LENGTH_SHORT).show()

}

//게임이 정상시작됨

while (game == true) {

//숫자가 랜덤으로 생성됨

pc = ran.nextInt(899) + 100

//생성된 숫자를 각각자리마다 쪼개서 중복비교를한다.

f = pc / 100

f_dump = f * 100

s_dump = pc - f_dump

s = s_dump / 10

s_dump2 = s * 10

t = s_dump - s_dump2

Log.d("user", "" + pc)

//3자리의 숫자중 중복이 발생하면 다시 숫자를 정하는 코드

if (f == s || s == t || t == f) {

pc = ran.nextInt(899 + 100)

} else {

tv.text = "예상되는 숫자를 입력하세요"

Toast.makeText(this@MainActivity, "게임이 시작되었습니다!", Toast.LENGTH_SHORT).show()

Log.d("game", "start")

game = false

break

}

}

}

play = findViewById(R.id.button2) as Button

play.setOnClickListener {

//게임시작을 누르지 않은 상태에서 비교버튼 눌렀을때의 처리

if (game == true) {

Toast.makeText(this@MainActivity, "아직 New Game 버튼을 누르지 않았습니다!", Toast.LENGTH_SHORT).show()

//게임이 진행중이며, 유저숫자와 비교를 하는 루프

} else if (game == false) {

user = Integer.parseInt(use.text.toString()) //값 입력받음

game = false //? 야 이거 왜있음? ㅋㅋㅋ

uf = user / 100

uf_dump = uf * 100

us_dump = user - uf_dump

us = us_dump / 10

us_dump2 = us * 10

ut = us_dump - us_dump2

//잘못된 범위의 숫자 입력시 처리

if (user <= 101 || user >= 1000) {

Toast.makeText(applicationContext, "잘못된 범위의 숫자입니다 (범위 : 102~999)", Toast.LENGTH_SHORT).show()

a = 0

} else {

a = 1

}

//중복수가 있는경우 처리

if (uf == us || us == ut || ut == uf && user < 101) {

Toast.makeText(applicationContext, "숫자가 중복될수 없습니다", Toast.LENGTH_SHORT).show()

b = 0

} else {

b = 1

}

if (a == 1 && b == 1) {

//스트라이크, 볼을 카운트 하는부분(정리하고싶다)

while (true) {

if (uf == f) {

str++

}

if (us == s) {

str++

}

if (ut == t) {

str++

}

if (uf == t) {

bal++

}

if (uf == s) {

bal++

}

if (us == f) {

bal++

}

if (us == t) {

bal++

}

if (ut == f) {

bal++

}

if (ut == s) {

bal++

}

count++

break

}

//카운트 완료되면 해당결과를 알려줌

if (str + bal == 0) {

Toast.makeText(applicationContext, "일치하는 수가 존재하지 않습니다", Toast.LENGTH_SHORT).show()

tv.text = "OUT!!"

} else {

Toast.makeText(applicationContext, "" + str + " 스트라이크, " + bal + "볼", Toast.LENGTH_SHORT).show()

tvs = Integer.toString(str)

tvb = Integer.toString(bal)

tv.text = "$tvs 스트라이크 $tvb 볼"

}

//스트라이크3개 = 정답 이기때문에 게임종료시킴킴

if (str == 3) {

Toast.makeText(this@MainActivity, "정답입니다! 핸드폰의 숫자는 $pc 였습니다!", Toast.LENGTH_SHORT).show()

Toast.makeText(this@MainActivity, "시도횟수 : $count", Toast.LENGTH_SHORT).show()

tv.text = "정답입니다!"

//카운트 초기화

count = 0

//게임 종료처리시킴

game = true

//다음게임으로 이동

val next = Intent(applicationContext, Main2Activity::class.java)

startActivity(next)

Log.d("Gamestat", "" + game)

}

str = 0

bal = 0

}

}

}

}

}

'''

이것이 변경된 코틀린 코드입니다...

configured 다 됬습니다...