hunachi’s diary

Android studio でお勉強してます。

SuperCon'17 to PCK'17予選 に 参加した話

Supercon
SupercomputingContest2017 - Supercomputing Programing Contest Official Site

予選では最適解を見つける部分の実装を担当し(貪欲解)多少は上手くいったらしく,どうにか本選に行く資格を得た。
本選では解法はどうあれ実装が間に合わず愚直解を提出。順位は中の下でした。Unit君(2年生で私より1つ年下)に実装頑張ってもらって感謝しかないです。
感想:「青春できた。頭が腐ってるので新しいものに取り替えたい。Tシャツ貰えて嬉しい。愛用してる。」

PCK'17 予選(
web-ext.u-aizu.ac.jp

Unit君と出た。


最初は慎重に2人で適当に1,2,3,5を解いた。

(実は3は私がこの時WA してた。)


その後Unit君は8, 私は6を担当。


6が意外とすぐ解き終わったので次は9の実装方法を考えることにした。
なぜ9だったのかと言うと7はUnit君が実装が面倒だから飛ばすけど解法は分かってると言ったからと9が解けそうな感じがしたので。

10も強連結成分分解かなぁって思ったけど実装方法知らなかった為諦めた。)


その前に3のWAに気が付いて解き直した。
ごめんなさい以外の感情がない。


Unit君が手元でデバッグしてる時にsegment tree の写経をするというのをしていた。


その後Unit君が8も無事AC、ラスト40分くらいしか無かったのでunit君がダッシュで7を実装しAC。 <プロ


この時私は頭がないので迷走してしまい貪欲の部分の処理でテンパってたので7の方をといといてもらうのを優先した(これは正しかった・・・)
このテンパりはUnit君に頭の手助けしてもらって解消された。


だが残り時間15分切っていたのでめっちゃ焦って実装してたけど間に合わず終了。

悲しすぎた。あと30分でいいから欲しさがあった。

8完3WA。

感想:「Unit君プロ。文鎮になれた。余談だがUnit君が残り1時間半になるまではコンテストは4時間あると思っててうけた(いいえ)。10位以内に入ってたら今度こそ沢山お金持ってUnit君におごるぞ🍚」


あとPCK'17 は本選いきます(モバイルの方)



追記:九州の地域枠で本選に行けることになりました!
   8AC2WAまでが10位以内だったらしくこれは完全に私のせいですね・・・ごめんなさい・・・
   モバイルの方と2部門ですが、頑張ります~!交通費2倍出してくれないかなぁ
   かなり人見知りのふなちですが、色んな方々とお話できるよう頑張ります🌰

databindingのerrorで毎回詰まってる話

Ⅰ.変数名のspellmiss

Ⅱ.ぽえええええ 原因が分かんないタイプのbuild errorぢゃん!

error文は以下の通り 

:app:kaptDebugKotlin
e: java.lang.IllegalStateException: failed to analyze: java.lang.annotation.IncompleteAnnotationException: android.databinding.BindingBuildInfo missing element enableDebugLogs
at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:144)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:182)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.execCompiler(CompileServiceImpl.kt:397)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$execCompiler(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:365)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:798)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:825)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$checkedCompile(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:797)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:791)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$doCompile(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:364)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:99)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:336)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.annotation.IncompleteAnnotationException: android.databinding.BindingBuildInfo missing element enableDebugLogs
at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
at com.sun.proxy.$Proxy32.enableDebugLogs(Unknown Source)
at android.databinding.annotationprocessor.BuildInfoUtil.load(BuildInfoUtil.java:35)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:59)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:73)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:42)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:205)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:166)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:82)
at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:89)
at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:99)
at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:76)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.analyze(KotlinToJVMBytecodeCompiler.kt:365)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:105)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:354)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:139)
... 40 more


FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Internal compiler error. See log for more details

 

ライブラリのversion問題だった in plagin

apply plugin: 'kotlin-kapt'
kapt 'com.android.databinding:compiler:2.3.3'

 compiler:2.3.3になってるか今すぐ確認しよう!versionが古いと死ねぞ!

directory名が変だけど・・・:;(∩´﹏`∩);:

new projectを生成したら、へんなdirectory名がついてた:;(∩´﹏`∩);:

 

package com.hoge.${package_name}.view.view.MainActivity

 

私はviewフォルダの中にviewフォルダを作りたいんじゃないよー!

~*.view.hogeにしたいの!!

 Refactor->Rename

からじゃだめみたい....

某同学年先輩に聞いたところ直接Codeのpathをかえてみたら?って教えてもらった!

package com.hoge.${package_name}.view

import android.os.Bundle
import android.support.v7.app.AppCompatActivity

/**
* Created by hunachi on 7/24/2017.
*/
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}

そしたらできました。

うう感謝。

gson,retrofitで@Path

gson,retrofitで@Path(だけなのかはわからないけど,)使うとデフォルトでhoge="hoge"のようにダブルクォーテーションがつくので、

e.g.

hoge=hoge

という風に送りたいのに

hoge="hoge"

になるといった症状です(@Partの副作用?:;(∩´﹏`∩);:?)

stackoverflow.com

これのSolution2をしましょう。

retrofit = Retrofit.Builder()
.baseUrl("")
.addConverterFactory(StringConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()

「StringConverterFactoryはGsonConverterFactoryの前に入れる!!」って注意書きが書いてあるのでそれは守りましょうね。

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class 

 というerrorが出た・・・!

これはMainfest.xmlにerrorの原因となっているclassが<activity>として定義されて無いからである。

だから

<activity android:name=".view.${className}"/>

 を追加してあげよ!

MediaPlayer (BGM用)

rawファイル(自分でsrcの中に作る)に音楽ファイルをコピペした時のTemplate.

fun setUpMusic() : Boolean{
var fileCheck = false
try {
mediaPlayer = MediaPlayer.create(this,R.raw.cave1)
fileCheck = true
}catch (e : IOException){
e.printStackTrace()
}
return fileCheck
}

fun playMusic(){
mediaPlayer.start()
}

fun stopMusic(){
mediaPlayer.stop()
mediaPlayer.reset()
mediaPlayer.release()
}

 

https://akira-watson.com/android/audio-player.html

参考にしました。 

あと、どくぴー先輩が教えてくださりました。

ありがとうございました。