万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    FlutterでAndroidでAdMobの初期化時にクラッシュする

    google_mobile_ads:のAdmobを使っている。

    firebase_admobはもうオワコン。

      ******************************************************************************
        * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
        * should follow the instructions here: https://goo.gl/fQ2neu to add a valid  *
        * App ID inside the AndroidManifest. Google Ad Manager publishers should     *
        * follow instructions here: https://goo.gl/h17b6x.                           *
        ******************************************************************************

    が最初出た。 https://qiita.com/masaibar/items/848362349442026063e2 こいつを参考にしたけど関係ない。

    android/app/src/main/AndroidManifest.xml に入れてるだろ〜あほか!

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.shinriyo.アプリ名">
       <application
            android:label="アプリ名"
            android:icon="@mipmap/ic_launcher">
            <activity
                android:name=".MainActivity"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
                android:hardwareAccelerated="true"
                android:windowSoftInputMode="adjustResize">
                <!-- Specifies an Android theme to apply to this Activity as soon as
                     the Android process has started. This theme is visible to the user
                     while the Flutter UI initializes. After that, this theme continues
                     to determine the Window background behind the Flutter UI. -->
                <meta-data
                  android:name="io.flutter.embedding.android.NormalTheme"
                  android:resource="@style/NormalTheme"
                  />
                <meta-data
                  android:name="io.flutter.embedding.android.NormalTheme"
                  android:resource="@style/NormalTheme"
                  />
                <!-- ここにいれていた />
                <meta-data
                    android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>

    しかし、meta-dataに倣ってやってたのだがドキュメント良く見たら applicationの直下であって、activityの直下ではない!!!

    developers.google.com

    公式は分かりづらい。Googleの社員はわかりやすさを考えよーぜ。頭でっかちなんだよ。

            </activity>
            <!-- つまりここ -->
            <meta-data
                 android:name="com.google.android.gms.ads.APPLICATION_ID"
                 android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
            <!-- Don't delete the meta-data below.
                 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
            <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
        </application>
    </manifest>

    https://blog.masterka.net/archives/1050 このブログ見ても 「広告のIDとapplication idは別なので注意」っていってるけどFirebaseのいれてるしなー。 どこだよ!!!分かりづらい。

    結論はここからたどる AdMob

    これ!!!

    f:id:shinriyo:20210620173010p:plain

    サブコレクションのみだけを取得したい時

    CollectionGroupを使う。

    待ち焦がれたCollectionGroupがCloud Firestoreへやってきた。 - Qiita

    Themeの中にcommentsというsub collectionみたいなやつがあったときに、

    Theme A
    - comments
    Theme B
    - comments

    なときに、AからもBからも取りたい需要がある。

          FirebaseFirestore.instance
              .collectionGroup('comments')
              .where('userId', isEqualTo: currentUserId)
              .orderBy('createdAt')
              .snapshots(),
     .collectionGroup

    を使う。

     Operation was rejected because the system is not in a state required for the operation's execution. If performing a query, ensure it has been indexed via the Firebase console.

    がうざい。

    それは

    https://console.firebase.google.com/u/0/project/プロジェクト名/firestore/indexes/single-field/manage

    にある、 「自動インデックス設定」タブにある除外をいじろう。

    f:id:shinriyo:20210606130013p:plain

    前置詞違うだけで意味変わる

    She made a great presentation to the board. 取締役会の前で彼女は素晴らしいプレゼンテーションを行った。

    このboard(boʊrd)は取締役会(a group of people with the power to make important decisions about how a business or organization works)

    to が重要