2015/9/29追記

kotlinのプロパティについて

getを使う前にsetで初期化が必要なようです。

エラー原因のプロパティ

//リスタートフラグ(ログアウト用)
var restartFlag: Boolean = false

Javaでいうフィールド変数の代わりは
下の例のように、クラス宣言して扱わないければいけないのでしょうか?

class Person() {
  var name : String = ""
}

fun main(args : Array<String>) {
  val taro = Person()
  taro.name = "Taro"
  println(taro.name) // Taro
}

ーーーーーーーーーーーーーーーーーーーーーーーーー
2015/9/28

WebView上のログアウト押下時、エラーが発生します。
画面上にダイアログ「hogehogeは問題が発生たため、終了します」

作ろうとした機能:WebView上の「ログアウト」押下時にログアウトのURLをリクエストして、restart()でアプリを再起動する。

(ログアウトをしたら、トップページのURLがリクエストされるので、これを表示せずにアプリを再起動したい)

    package jp.yahuu.hogehoge.app.activities

    import android.content.Intent
    import android.net.Uri
    import android.os.Bundle
    import android.webkit.JavascriptInterface
    import android.widget.Toast
    import jp.yahuu.hogehoge.app.R
    import jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager
    import jp.yahuu.hogehoge.app.constants.Constants
    import jp.yahuu.hogehoge.app.data.feed.user.User
    import jp.yahuu.hogehoge.app.fragment.WebFragment
    import jp.yahuu.hogehoge.app.proguardHelper.NonObfuscate
    import jp.yahuu.hogehoge.app.web.*
    import kotlin.properties.Delegates

    //import kotlinx.android.synthetic.web_fragment.*

    /**
     * Created by henrique on 2/13/15.
     */

    //リスタートフラグ(ログアウト用)
    var restartFlag: Boolean = false

    public class WebViewActivity(var uri: Uri? = null): DefaultActivity() {

        //ログインページがリクエストされた場合に1になるフラグ
       // var loginPageFlag  = 0;





        private class WebViewFragment():
                WebFragment(),
                AdEventHandlerDelegate,
                FavorEventHandlerDelegate,
                ShareEventHandlerDelegate,
                NewPageEventHandlerDelegate,
                LoginPageEventHandlerDelegate,
                LogoutPageEventHandlerDelegate
        {
            private object KeyName {

                val Uri = "Uri"

            }

    //        class Flag() {
    //            //リスタートフラグ
    //            var restartFlag: Boolean = false
    //
    //        }







            public companion object {
                //Function型 fun
                public fun newFragment(uri: Uri): WebViewFragment {

                    val fragment = WebViewFragment()

                    val args = Bundle()
                    args.putString(KeyName.Uri, uri.toString())

                    fragment.setArguments(args)

                    return fragment

                }

            }

            private fun getWebViewActivity(): WebViewActivity {

                return getActivity() as WebViewActivity

            }

            override fun getEventHandlers(): Collection<EventHandler> {

                return arrayListOf(
                        AdEventHandler(this),
                        FavorEventHandler(this),
                        ShareEventHandler(this),
                        CurrentPageEventHandler(this),
                        NewPageEventHandler(this),
                        LoginPageEventHandler(this),
                        LogoutPageEventHandler(this)
                )

            }

            override fun setupWebView() {

                super<WebFragment>.setupWebView()

                webView.addJavascriptInterface(object: NonObfuscate {

                    JavascriptInterface
                    public fun startSharing(url: String, title: String) {

                        val intent = Intent(Intent.ACTION_SEND)
                        intent.setType("text/plain")
                        intent.putExtra(Intent.EXTRA_TEXT, title + "\n" + url)
                        intent.putExtra(Intent.EXTRA_SUBJECT, title)

                        startActivity(Intent.createChooser(intent, "共有"))

                    }

                }, "Android")

            }

            // Delegates methods
            override fun openAd(uri: Uri) {

                openUri(uri)

            }

            private fun enfavor(identifier: Int) {

                User.addBookmark(identifier)

                Toast.makeText(getActivity(), "お気に入りに登録しました", Toast.LENGTH_LONG).show()

            }

            private fun defavor(identifier: Int) {

                User.removeBookmark(identifier)

                Toast.makeText(getActivity(), "お気に入りから削除しました", Toast.LENGTH_LONG).show()

            }

            override fun favorEvent(eventType: FavorEventType, identifier: Int) {

                when (eventType) {

                    FavorEventType.Enfavor -> enfavor(identifier)
                    FavorEventType.Defavor -> defavor(identifier)

                }

            }

            override fun shareEvent() {

                webView.loadUrl("javascript:Android.startSharing(get_actual_URL(),get_actual_title());")

            }

            //新しいアクティビティの場合?
            override fun openUriInNewPage(uri: Uri) {

                openUriInNewWebViewActivity(uri)


            }


            override fun showLoginPage() {

                val uri = Uri.parse("https://yahuu-ni.jp/users/sign_in")
                openUriInNewPage(uri)

            }






            override fun userWillLogout() {

                //クッキーを削除して、トップ画面に遷移する。

                println("ログアウトをタッチした。")

                val uri = Uri.parse("https://yahuu-ni.jp/logout")
                openUriInNewPage(uri)

                restartFlag = true


    //            //再起動フラグを上げる
    //            restart()

    //            //ダイアログでログアウトを選択した場合?
    //            userDidLogout()

    //            val uri = Uri.parse("https://yahuu-ni.jp/logout")
    //            openUriInNewPage(uri)

            }



            override fun userDidLogout() {
                println("userDidLogout")
            }

        }

        private object RegexPattern {

            val ArticlePattern = "-?\\d+(\\.\\d+)?"

        }

        private val articleRegex by Delegates.lazy {

            WebViewActivity.RegexPattern.ArticlePattern.toRegex()

        }

        private fun setupUri() {



                if (this.uri == null) {

                    //varは通常の変数
                    var u = getIntent()
                            .getStringExtra(
                                    getResources()
                                            .getString(R.string.default_webview_activity_uri)
                            )
                    println("u: $u")

                    //トップページがリクエストされた場合
                    //ログイン後遷移http://yahuu-ni.jp/,アプリ起動時https://yahuu-ni.jp/

                    //ログアウト後遷移https://yahuu-ni.jp/

                        if(u.equals("http://yahuu-ni.jp/") || u.equals("https://yahuu-ni.jp/")){
                           //上書きuri
                            u = "http://yahuu-ni.jp/mypage"
                        }



                        //urlがnullじゃない場合
                        if (u != null) {


                            //もしuがnullの場合NullPointerExceptionヤッホー
                            val parsedUri = Uri.parse(u)

                            //ドメインがヤッホー(teru or false)
                            val ishogehoge = Constants.ishogehogeDomain(parsedUri
                            )


                            //ドメインがヤッホーの場合
                            val newUri: Uri = if (ishogehoge) {


                                println("parsedUri: $parsedUri")
                                println("articleRegex: $articleRegex")


                                // ログイン済みの場合、「https://yahuu-ni.jp/」が再リクエストされてここ落ちる
                                //パス部がnull
                                //parsedUri → https://yahuu-ni.jp/users/sign_in isArticle:false
                                val isArticle = parsedUri.getLastPathSegment().matches(articleRegex)
                                println("isArticle: $isArticle")

                                //article(記事)の場合?
                                val builder: Uri.Builder = if (isArticle) {

                                    val identifier = parsedUri.getLastPathSegment().toInt()

                                    User.addHistory(identifier)

                                    val favored = User.containsInBookmark(identifier)

                                    val flag = if (favored) {
                                        1
                                    } else {
                                        0
                                    }

                                    parsedUri.buildUpon()
                                            .appendQueryParameter("favored", "$flag")


                                    //記事以外の場合
                                } else {


                                    parsedUri.buildUpon()

                                }

                                builder.appendQueryParameter(
                                        "idfa",
                                        AdvertisingIdentifierManager.information.identifier
                                ).build()

                            } else {

                                parsedUri

                            }

                            this.uri = newUri

                            println("new Uri: $newUri")



                        }



                }


        }


        //リスタート処理
        private fun restart(){
            println("restart")
            if (restartFlag) {
    //            //fragmentの終了 onDestroyが呼び出される
    ////            getFragmentManager().beginTransaction().remove(this).commit()
    //
    ////            getFragmentManager().popBackStack()
    //            activity.finish();



                val intent = getIntent()
                overridePendingTransition(0, 0)
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
                finish()
                overridePendingTransition(0, 0)

                startActivity(intent)


            }
        }

        /***
         * Fragmentが破棄される時、最後に呼び出される
         */
        @Override
        override fun onDestroy() {
    //     まずはデストロイを走らせる、アクティビティのフィニッシュか?fragmentか?   http://attyo0.blog.fc2.com/blog-entry-9.html

 super<DefaultActivity>.onDestroy()

            println("onDestroy")
            if (restartFlag) {
                restartFlag = false;
                //ここにメインアクティビティのインテント

                //            val intent = Intent(getApplicationContext(), javaClass<MainActivity>())
                ////            intent.putExtra(getResources().getString(R.string.default_webview_activity_uri), uri.toString())
                //
                //            startActivity(intent)
                println("ここにメインアクティビティのインテント")
            }
        }


        override fun onCreate(savedInstanceState: Bundle?) {

            super<DefaultActivity>.onCreate(savedInstanceState)
            setContentView(R.layout.activity_webview)

            //ログアウト
            if (restartFlag) {
                println("restart() アプリ再起動")
                restart()
            }

            println("setupUri()")
            setupUri()

            if (savedInstanceState == null) {

                val newFragment = WebViewFragment.newFragment(uri!!)

                getFragmentManager()
                        .beginTransaction()
                        .add(R.id.web_view_container, newFragment)
                        .commit()

            }

            getSupportActionBar().hide()

        }



    }

エラーログ(エラーのダイアログは6回出た後にアプリが終了したが、これは1回目のログ)

09-28 16:46:39.384  17677-17677/? I/art﹕ Late-enabling -Xcheck:jni
09-28 16:46:39.512  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Crash reporting is enabled for jp.yahuu.hogehoge.app, initializing...
09-28 16:46:39.524  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Looking for error files in /data/data/jp.yahuu.hogehoge.app/files/com.parse/cr/reports
09-28 16:46:39.524  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Looking for error files in /data/data/jp.yahuu.hogehoge.app/files/com.parse/cr/minidumps
09-28 16:46:39.591  17677-17677/jp.yahuu.hogehoge.app I/System.out﹕ setupUri()
09-28 16:46:39.592  17677-17677/jp.yahuu.hogehoge.app I/System.out﹕ u: https://hogeho-ge.jp/logout
09-28 16:46:39.592  17677-17677/jp.yahuu.hogehoge.app I/System.out﹕ parsedUri: https://hogeho-ge.jp/logout
09-28 16:46:39.600  17677-17677/jp.yahuu.hogehoge.app I/System.out﹕ articleRegex: -?\d+(\.\d+)?
09-28 16:46:39.601  17677-17677/jp.yahuu.hogehoge.app I/System.out﹕ isArticle: false
09-28 16:46:39.601  17677-17677/jp.yahuu.hogehoge.app D/AndroidRuntime﹕ Shutting down VM
09-28 16:46:39.601  17677-17677/jp.yahuu.hogehoge.app E/CrashReporting﹕ ParseCrashReporting caught a RuntimeException exception for jp.yahuu.hogehoge.app. Building report.
09-28 16:46:39.603  17677-17677/jp.yahuu.hogehoge.app E/CrashReporting﹕ Handling exception for crash
    java.lang.RuntimeException: Unable to start activity ComponentInfo{jp.yahuu.hogehoge.app/jp.yahuu.hogehoge.app.activities.WebViewActivity}: java.lang.IllegalStateException: Property _information should be initialized before get
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.IllegalStateException: Property _information should be initialized before get
            at kotlin.properties.NotNullVar.get(Delegation.kt:124)
            at jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.get_information(AdvertisingIdentifierManager.kt)
            at jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.getInformation(AdvertisingIdentifierManager.kt:73)
            at jp.yahuu.hogehoge.app.activities.WebViewActivity.setupUri(WebViewActivity.kt:304)
            at jp.yahuu.hogehoge.app.activities.WebViewActivity.onCreate(WebViewActivity.kt:389)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
09-28 16:46:39.603  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Generating report file for crash
09-28 16:46:39.677  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Retrieving logcat output...
09-28 16:46:39.715  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Retrieving logcat output...
09-28 16:46:39.737  17677-17677/jp.yahuu.hogehoge.app D/CrashReporting﹕ Retrieving logcat output...
09-28 16:46:39.838  17677-17677/jp.yahuu.hogehoge.app V/CrashReporting﹕ About to start ReportSenderWorker from #handleException
09-28 16:46:39.842  17677-17721/jp.yahuu.hogehoge.app D/CrashReporting﹕ #checkAndSendReports - start
09-28 16:46:39.842  17677-17721/jp.yahuu.hogehoge.app D/CrashReporting﹕ Looking for error files in /data/data/jp.yahuu.hogehoge.app/files/com.parse/cr/reports
09-28 16:46:39.844  17677-17721/jp.yahuu.hogehoge.app D/CrashReporting﹕ Loading file 1443426399603-IllegalStateException-10.stacktrace
09-28 16:46:39.846  17677-17721/jp.yahuu.hogehoge.app W/CrashReporting﹕ 65403-byte crash report 1443426399603-IllegalStateException-10.stacktrace exceeded max size of 51200 bytes; deleted
09-28 16:46:39.846  17677-17721/jp.yahuu.hogehoge.app D/CrashReporting﹕ #checkAndSendReports - finish
09-28 16:46:39.938  17677-17677/jp.yahuu.hogehoge.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: jp.yahuu.hogehoge.app, PID: 17677
    java.lang.RuntimeException: Unable to start activity ComponentInfo{jp.yahuu.hogehoge.app/jp.yahuu.hogehoge.app.activities.WebViewActivity}: java.lang.IllegalStateException: Property _information should be initialized before get
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.IllegalStateException: Property _information should be initialized before get
            at kotlin.properties.NotNullVar.get(Delegation.kt:124)
            at jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.get_information(AdvertisingIdentifierManager.kt)
            at jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.getInformation(AdvertisingIdentifierManager.kt:73)
            at jp.yahuu.hogehoge.app.activities.WebViewActivity.setupUri(WebViewActivity.kt:304)
            at jp.yahuu.hogehoge.app.activities.WebViewActivity.onCreate(WebViewActivity.kt:389)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

2015/09/29 追記ーーーーーーーーーーーーーーーー

Caused by: java.lang.IllegalStateException: Property _information 
should be initialized before get 
                at kotlin.properties.NotNullVar.get(Delegation.kt:124) 
                at 
jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.get_information(AdvertisingIdentifierManager.kt) 
                at 
jp.yahuu.hogehoge.app.advertising.AdvertisingIdentifierManager.getInformation(AdvertisingIdentifierManager.kt:73) 

「getを使う前にsetで初期化してください。」とのことです。