カテゴリー: Android

うにのトゲは刺さると痛い(´・ω・`)-40 : Javaプラグインの利用 (Java側)

きっと他のことをやって全てを忘れてしまう未来の俺氏へのUnityで自作Javaプラグインを利用する時のJava側手順。

何故か他の人のコードを実行しようとすると上手く行かなかったので、Unity側から文字列を渡して、それにJava側が文字列を付加して返すという簡単なものにした(´・ω・`)

面倒だったのでAndroid10決め打ちにした。
日本語化が上手く行ってないのか、メニュー等がなんか中途半端な状態になっているw

参考サイトというか目を通したり試したエントリはたくさんあるのだが、ブックマークに残っていたのは下の3つくらいだった(ノ∀`)マタヤラカシタ
Unityのプラグインを作るAndroid/iOS
[Android]Unityへ組み込むAndroidライブラリビルド手順解説
突然仕事でUnity向けのSDKやPluginを作ることになった人向け資料


他の人のエントリを色々読み、理解せずにやっていたから気が付かなかったが、手順8~11のUnityのClass.jarのコピーにまつわる作業は、Java側でUnityPlayerActivity等をいじったりしない場合は必要ない気がする…( ・´ω・`)トバシテイイ


  1. Android Studioを起動し、[Create New Project]をクリック。
  2. [No Activity]を選択し<次へ>をクリック。
    ※目的はモジュール作成の為、実際にはActivityは何を選んでも問題はない筈。

  3. 任意のプロジェクト名を指定し、[Minimum SDK]で"API 29 Android 10.0"を選択し、<終了>をクリック。
    ※うちの実機はAndroid10なのでこの選択をしているが、必ずしも10でなければならないわけではない。但し、他のバージョンでは動作確認をしていない。
  4. プロジェクトの作成が終わったら、[ファイル]-[New]-[New Module]の順に選択。
  5. [Android Library]を選択し、<次へ>をクリック。
  6. [Module Name]に任意の名前を指定、[Minimum SDK]で"API 29 Android 10.0"を選択し、<終了>をクリック。
    ※この例では[Module Name]を"UniAndLib"に指定。
  7. <プロジェクト>プルダウンをクリックし、"プロジェクト"をクリック。
  8. 使用する予定のバージョンのUnityのフォルダで"Class.jar"をコピー。
    この例ではUnity Hubを使用し、バージョン 2020.2.4f1 を使用。かつmonoではなくil2cppでビルド。
    "C:\Program Files\Unity\Hub\Editor\2020.2.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp\Release\Classes"

    カスタムインストール時は当然のことながら、Class.jarの在り処は変わってくる。

  9. Android Studioのプロジェクトの新しく追加したモジュール配下のlibsフォルダに貼り付け。
  10. ダイアログが表示されたら、<リファクタリング>をクリック。
  11. 新しく追加したモジュール配下のbuild.gradleをダブルクリック。
  12. build.gradleが表示されたら、dependenciesの箇所に
    compileOnly fileTree(dir: 'libs', include: ['*.jar'])
    compile 'androidx.appcompat:appcompat:1.1.0'
    

    を追加。

    これを追加しておかないと、"Execution failed for task ':launcher:checkDebugDuplicateClasses'"とかいうエラーが出る筈。Android Studioで作ったライブラリ側とUnity側にUnityのClass.jarが存在しちゃって、その辺がいけないらしい…

    ※compileのところに打ち消し線が出るのでDeprecatedかなにかなのかもしれないがキニシナイ( ゚ 3 ゚)
    もしかしたらそもそも必要ないのかな? よくよく見ると下の行で"appcompat:1.2.0"をimplementationしてるから要らないか?

  13. 新しく追加したモジュール配下の[src]-[main]--[パッケージ名]のフォルダを右クリックし、コンテキストメニューが表示されたら、[新規]-[クラス]の順に選択。

  14. 「New Java Class」ダイアログが表示されたら、クラス名を指定し、"Class"をクリック。
    ※この例ではクラス名に"ReturnString"を指定。
  15. 作成したクラスがエディタに表示されたら、以下の内容を入力して保存。
    package com.example.uniandlib;
    
    public class ReturnString {
        public String returnResult(String fromUnity) {
            return "Via Java Lib:\n" + fromUnity;
        }
    }
    

    (パッケージ名やクラス名を任意の値を指定している場合は適宜書き換える。)

  16. メニューで[ビルド]-[Rebuild Project]の順に選択。
  17. ビルドが終了するまで待つ。
    (ウィンドウ下のステータスバーで以下のようなの表示がされている間はビルド実行中。)

以上がUnityで使用できるJavaプラグインの作成方法。

画像を入れたら長くなりすぎたので、Unity側は次のエントリで…(ヽ'ω`)


CommandInvokationFailure: Gradle build failed.

このエラーが出た場合は、一回エクスポートして、Android Studio側でインポートしてGradleをアップグレードしないといけないとかどうとか。

参考:
Gradle build failedが出る(Unity2019から)

プライバシーポリシーのなんちゃらこうちゃらで…

「アプリの公開を停止しちゃるでー(・∀・)」とごっぐるからメールが来た。

"Google Play配布契約 4.8 への違反対応"とか言うやつ(´・ω・`)?
よくわからんからぐぐった。

結論から言うとadmobやfirebaseを使ってるとそれらがやっている情報収集がGDPRとかその辺のなんらかに抵触するからプライバシーポリシーの表示をするようにしないと駄目よんというようなお話らしい(・∀・) ←ヨクワカッテナイ

プライバシーポリシーの項目はGoogle Play Consoleのアプリのページ内にあったが、しばらくは用意しなくても大丈夫そうだったので放置していたのがいけなかったのだ(ノ∀`)

参考:
AdMob, Firebase付きAndroidアプリのプライバシーポリシー、こうしてみました(要経過観察)
【広告ID】Google Play配布契約 4.8 への違反対応


参考にしたページの方やら、他の人達はadmobとfirebaseの2つを使っているので、その2つに対するプライバシーポリシー宣言文(?)を用意していたが、俺氏のアプリは今の所admobだけなのでfirebaseの方は端折った。admobの方の文をまるごとパクり参考にプライバシーポリシー宣言用のHTMLを作った。

参考ページその他を読んでいると、アプリ側でも初回起動時に強制的に表示するか、広告IDの収集をやめさせないといけないよう(UnityでそれをやるためにはAndroidManifest.xmlをいじらなくちゃいけないような雰囲気)だったので

取り敢えず、この件は放置することにした(ノ∀`)

更新をかけるにはまだ中学生漢字のデータが出来ていないし、もし更新するなら、その他のバグというかデータの誤りも直して出したいし。どうせ公開していてもユーザーは全然増えてないしw


などと思ってGoogle Play ConsoleのプライバシーポリシーのURLを追加して、「アップデートを送信」とかいうボタンをクリックした。

それでまぁ、そのことは忘れて他のことをやっていた。
しばらくしてAndroid端末を見たら、アプリの更新要求が表示されていた。従った。

それからまたしばらくしてAndroid端末を見たら更新が終わっていた。
何故かその中にMole's Match-upのアイコンがΣ(゚∀゚;)

俺氏が寝ている間に小人さん達が勝手にバグ取りとかデータ内容の更新をしてリリースしてくれたんだな(・∀・)と呑気に考えてみたが、そんなはずもなく。

まあ普通に考えたらプライバシーポリシーURLの更新によるものだろう……
で、それもまあともかくとGoole Play Consoleを見に行く。

あれ(´・ω・`)? 公開停止が解除されてね?

どういうこと(´・ω・`)?
プライバシーポリシーURLをGoogle Play Consoleに追記すれば解決するだけの話だったのかな?


まあ、どうでもいいか(・∀・)

Neko Astume (Collect cats) have been updated to Ver.1.4.0.

・Help and other links are here.

・This entry may include "ネタバレ". "ネタバレ(ねたばれ netabare)" means the information that disclose the core part and the detail of a game, novel, manga, movie, etc.

That is, Spoiler Alert!


Ver. 1.4.0 update

  • Added new cats.
    新ねこが追加されました。
  • Added new goods.
    新グッズが追加されました。
  • Added the capability of extending the photographing range.
    個別カメラの撮影範囲を広げることができるようになりました。
     
    In the individual camera screen, you can scale down it by doing pinch-in, and scale up by doing pinch-out.
    個別カメラ画面で画面をピンチインで縮小、ピンチアウトで拡大できます。
    normal-photographing_range              ↓
    extend-photographing_range
  • Increased in the max number of photograph of the "Free Album" to 72 sheets from 48 sheets.
    フリーアルバムの数が48枚から72枚に増加しました。
  • Added the capability of adding page of each album.
    各アルバムのページが追加できるようになりました。

    Free Album max 16 pages( 96 sheets) individual album of cats max 8 pages ( 48 sheets)
    フリーアルバム最大16ページ(96枚) ねこ個別アルバム最大8ページ(48枚)

    The adding of one page require "10 gold niboshi".
    ※ 1ページの追加には「10金にぼし」が必要です。


Goods

goods-capsuleball
カプセル玉(かぷせるだま kapuseru dama) capsule ball

“カプセル”は日本語表記での”capsule”です。
“カブセル” is “capsule” in Japanese notation.

玉は通常、ボールや球形のものを意味します
玉 means usually a ball or sphere.

"カプセル玉"はガチャガチャの玩具の入れ物です。
"カプセル玉" is a container of Gacha Gacha toy.

Gashapon
ガチャガチャ - Google Images

goods-momiji_zabuton

もみじ座布団(もみじざぶとん momiji zabuton)

"もみじ 紅葉 momiji" is a Japanese maple.
This is a zabuton with Cover of pattern of Japanese maple.

もみじ - Google Images

goods-orange_cubegoods-navy_cube
goods-tiramisu_cubegoods-saikoro_cube

オレンジキューブ/ネイビーキューブ/ティラミスキューブ/サイコロキューブ

This is a cube-type house for cat and dog.

“オレンジ”は日本語表記での”orange”です。
“オレンジ” is “orange” in Japanese notation.

“ネイビー”は日本語表記での”navy”です。
“ネイビー” is “navy” in Japanese notation.

“ティラミス”は日本語表記での”tiramisu”です。
“ティラミス” is “tiramisu” in Japanese notation.

"サイコロ" means a dice.

tiramisu - Google Images

キューブハウス 猫 - Google images

goods-dometype_cousion_blackgoods-igaguri_cousion

ドーム型ブラック/いがぐりクッション

“ドーム”は日本語表記での”dome”です。
“ドーム” is “dome” in Japanese notation.

“ブラック”は日本語表記での”black”です。
“ブラック” is “black” in Japanese notation.

"いがぐり 毬栗 iga guri" means a chestnuts in burrs.

“クッション”は日本語表記での”cushion”です。
“クッション” is “cushion” in Japanese notation.

いがぐり - Google imagas

goods-tsubotsuki_wadansu
壺付き和箪笥(つぼつきわだんす) tsubo tsuki wadansu

"壺 つぼ tsubo" means a pot.
"付き つき tsuki" means "with".
"和 わ wa" means "Japanese", in this case.
"箪笥 たんす tansu" means a chest of drawers.

このタイプの"和箪笥"は階段としての機能も持っていました。
This type of ”和箪笥” also had a function as a staircase.

和箪笥 階段 - Google images

goods-susuki_ jarashi
すすきじゃらし susuki jarashi

”すすき” means Japanese pampas grass.
"じゃらし" means a name of toy for cat(dog or baby) . Strictly speaking,this may be wrong :p

Japanese pampas grass - Google Images

goods-kerigurumi_sanma
けりぐるみ(サンマ)

------------------------------------------------------------------------
It is said that if give it cats,many cat is excited and kick it.
"keri/keru" means "kick", "nuigurumi" means "stuffed toy" in Japanese Language.
So it probably was named Kerigurumi.
Kerigurumi is seems brand name.There is a product that contain Matatabi(silvervine).

Google Images けりぐるみ

Google Videos けりぐるみ

------------------------------------------------------------------------

"サンマ 秋刀魚 さんま sanma" means a Pacific saury.

Pacific saury - Google Images

goods-ponpon_ochibayama
ぽんぽん落ち葉山 ponpon ochiba yama

"落ち葉 おちば ochiba" means a fallen leaf.
"山 やま yama" means a mountain.

I have no idea what means "ぽんぽん".
"ぽんぽん" may represent an onomatopoeia.

This cushion is designed in the image of the mountain of fallen leaves and made of cloth.

落ち葉の山 - Google Images

goods-tarai
たらい

"たらい 盥 tarai" means a washtub.

たらい - Google Images

goods-nekomakaron_pinkugoods-nekomakaron_guri-n

ねこマカロン(ピンク/グリーン)

“マカロン”は日本語表記での”macaron”です。
“マカロン” is “macaron” in Japanese notation.

This cushion is designed in the image of the Macaron.

macaron - Google Images

goods-neko_dorayaki
ねこどらやき

どらやきは和菓子の一種です。
Dorayaki is a kind of Japanese confection.

Dorayaki

It is a great favorite of ドラえもん(Doraemon).

どら焼き - Google images

Neko Astume (Collect cats) – Goods list [ Food & etc]

* Help and other links are here.

* This entry may include "ネタバレ". "ネタバレ(ねたばれ netabare)" means the information that disclose the core part and the detail of a game, novel, manga, movie, etc.

That is, Spoiler Alert!


goods-otokuyoukarikari

お徳用かりかり(おとくようかりかり) otokuyou karikari
dry cat food value pack
 
Description of the goods
お徳用かりかり
贅沢品ではないけれど
味も大きさもまぁ合格

dry cat food value pack
Though it is not a luxury food,
the taste and size make the passing mark passably.

etc
This does not take the cost, you can set up endlessly.

"かりかり"はおそらく猫がドライペットフードをかじる時に起こる音に由来しているのでしょう。
"かりかり" would probably come from the sound that occurs when the cat gnaw the dry pet foods.


goods-koukyuukarikari

高級かりかり koukyuu karikari
high-class dry cat food

Sales Talk
高品質な食材を使用したバランスのとれた総合栄養食
ねこあつめ力がアップ!

A complete and balanced cat food which is well-balanced using high-quality ingredient.
"Attracting cats" power go up.

Description of the goods
高級なかりかり
豪華な材料が使われていて
味もなかなか良い

high-class dry cat food
it uses luxurious ingredient and tastes good.


goods-nekokan

猫缶 neko kan
canned cat food

Sales Talk
マグロ&カツオの大人気猫缶
しらす配合で栄養も満点!
ねこあつめ力が激アップ!!

Very popular canned cat food of the tuna & bonito.
The nutrition is also perfect by combining the young sardines!
"Attracting cats" power go up sharply.

Description of the goods
パキュ!
の音だけでどこからともなく
ねこがくる不思議な缶詰

The wonder can that cats comes from nowhere,
once they hear the sound of "Pakyu!" (The sound of opening a can. A onomatopoeic word.)


goods-katsuobushinekokan

かつおぶし猫缶 katsuobushi neko kan
Canned cat food with Katsuobushi Furikake

Sales Talk
大人気猫缶にかつおぶしのふりかけ付きが登場!
長時間の満足を保障! ←保証

A new product of popular cat cans series with the Furikake of Katsuobushi appeared!
We guarantee long-term satisfaction.

Description of the goods
かつおぶし(減塩タイプ)の
ふりかけつきの猫缶
ねこたちの遊ぶ時間が延びるかも

A cat cans with the Furikake of Katsuobushi(low-salt type).
Time for cats to play might extend.

etc
Katsuobushi(鰹節 かつおぶし) or okaka(おかか) is the Japanese name for dried, fermented, and smoked skipjack tuna (Katsuwonus pelamis).

The Furikake means rice seasoning or dried seasoning powder.


goods-koukyuumaguronekokan

高級マグロ猫缶 koukyuu maguro neko kan
high-class canned cat food of tuna
 
Sales Talk
上質のマグロのみを使用することで
味にうるさいねこちゃんも大絶賛!
ねこちゃんとの距離もぐっと近づくはず!

Even pussy who is very particular about foods rave about this which is made from only a high-quality tuna!
The distance with pussy should become shorten much!

Description of the goods
パキュ!の音とともに溢れる香りが
ねこたちを惹きつけてやまない

A fragrance to overflow with a sound of Pakyu greatly attract cats.


goods-osashimi

お刺身 osashimi
sashimi or sliced raw fish

Sales Talk
新鮮な魚のお刺身
サビ・ツマ抜きでねこちゃんも安心!
高級志向のねこちゃんに是非!

Sashimi of a fresh fish.
Even if the cat eats, it is safe because of without wasabi and tsuma!
We would like to recommend to a pussy who prefer to high-class.

Description of the goods
好き嫌いはあるけれど
そのニオイの吸引力は抜群
レアなねこたちには大人気

There are both the cat liking this and the cat disliking this,but the attraction of the perfume is outstanding.
It is extreme popularity for rare cats

etc
Sabi means the abbreviation of 山葵(わさび wasabi).
Wasabi means the Japanese horseradish. It is very spicy & tangy.
What is Wasabi? (with pictures)

Tsuma means garnish of Sashimi(such as wasabi,white radish, a leaf of beefsteak plant,etc).

刺し身のつま - Google Images


舟盛り funamori
sashimi boat

Sales Talk
パーティやお祝いの席に
会場が盛り上がること間違いなし!

There is no doubt that the banquet hall will be lively at parties and celebrations!

Description of the goods
沢山お刺身が敷き詰められているけれど
ねこたちのテンションも上がって
あっという間になくなっちゃいそう

There is a lot of sashimi spread all over the place, but the cats are so excited that they seem to be gone in no time.

etc
Funamori means served sashimi on a vessel shaped like a ship.

舟盛り - Google Images


goods-niboshikoukan

にぼし交換 niboshi koukan
Niboshi Exchange

Sales Talk
金にぼし10こを
ふつうのにぼし250こに交換

Exchange golden niboshi(10) to normal niboshi(250).

etc
Niboshi(にぼし/煮干し) is a small fish that is boiled and dried, and is like a currency in this game.

Google Images 煮干し


goods-kinniboshikoukan

金にぼし交換 kin niboshi koukan
Kin Niboshi Exchange
Sales Talk
ふつうのにぼし500を
金にぼし10こに交換

exchange normal niboshi(500) to golden niboshi(10).

etc
金 きん kin gold /かね kane money


goods-niwasakikakuchou

にわさき拡張 niwasaki kakuchou
Expanding the area

Sales Talk
にわさき拡張
ねこたちを集める場所を
お部屋側へ広げます
より沢山のグッズを設置できます

Expanding the yard
Expand the place where cats can come to play to the room side.
More a lot of goods can be installed.