【AndroidStudio】Debug Console の ログ フィルター がないので fold する方法

Retrofit でテストしてみたらログが見づらい。

WARNING: An illegal reflective access operation has occurred

何なんですかね。

まずこれ。


WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/Users/mersan/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit2/retrofit/2.8.0/53fa357bd7538d2c4872bddf33654f113cf6652b/retrofit-2.8.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Groovy と Java のバージョンによる相性なのか、なんなのか、よくわからん。

👉 [GROOVY-8339] Fix warning "An illegal reflective access operation has occurred" - ASF JIRA hatena-bookmark
👉 [GROOVY-9103] CLONE - CLONE - Fix warning "An illegal reflective access operation has occurred" - ASF JIRA hatena-bookmark

これについて、Jake さんは問題ないと言っています。

The reflection works around a bug in the JDK which was fixed in 14 but it's only used for default methods. As it's only a warning, it's not preventing your call from working.

👉 Illegal reflective access · Issue #3341 · square/retrofit hatena-bookmark

あと、Retrofit のログも見づらい。


Apr 12, 2023 10:19:16 AM okhttp3.internal.platform.Platform log
INFO: Server: cloudflare
Apr 12, 2023 10:19:16 AM okhttp3.internal.platform.Platform log
INFO: CF-RAY: 7b67a3d78f9f2647-NRT
Apr 12, 2023 10:19:16 AM okhttp3.internal.platform.Platform log
INFO: alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
Apr 12, 2023 10:19:16 AM okhttp3.internal.platform.Platform log
INFO: <-- END HTTP

まあ、Level.NONE にすれば消えるのだが、通信状態は見えなくなるし。


val interceptor = HttpLoggingInterceptor().apply {
  level = if (BuildConfig.DEBUG) Level.BODY else Level.NONE
}

👉 【Retorofit】コピペで使える NetworkModule【Dagger Hilt】 hatena-bookmark

 

■ Filter messages in Android Studio debug console

こんな機能あったんですね。

Right click on the line you want to hide, on the popup menu click "Fold lines like this". You'll be prompted a window where you can edit the folded lines content.

Ps. Folded lines content work the way contains string method does.

👉 Filter messages in Android Studio debug console - Stack Overflow hatena-bookmark

隠したい行で右クリックから Fold Lines Like This です。

折り畳まれて、とりあえずは見やすくなりました!

まだまだ使ったことのない知らない機能がたくさんありますわあ。


AndroidStudioでMarkdownプレビューが表示されない時の対処法

プラグインは対応はしてるのに未だ表示されず。

👉 Markdown - IntelliJ IDEs Plugin | Marketplace hatena-bookmark

一時期は表示されてたことありませんでしたっけ。

 

■ プレビューを表示させる

これ。

The Java Chromium Embedded Framework (JCEF) is a simple framework for embedding Chromium-based browsers in other applications using the Java programming language.

👉 JetBrains/jcef: A simple framework for embedding Chromium-based browsers into Java-based applications. hatena-bookmark

AndroidStudio 稼働のための Java を JCEF が含まれているものに変更すればプレビューを表示できるようです。

[email protected] #19Jun 30, 2022 12:57PM
Based on #7

TLDR for https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under:

In the Android Studio:

1. Find action (ctrl + shift + A / command + shift + A)
2. Search for Choose Boot Java Runtime for the IDE
3. Select the latest version in the "New:" dropdown - e.g. 11.0.12+7-b1504.27 JetBrains Runtime with JCEF
4. OK
5. Restart
Worked in: Android Studio Chipmunk | 2021.2.1 Patch 1 | Build #AI-212.5712.43.2112.8609683

👉 Regression in markdown support (crashes 100% of the time). Missing JCEF [159933628] - Visible to Public - Issue Tracker hatena-bookmark

リスタートすると正しく表示されました。

 

■ まとめ

[email protected] #20Jul 1, 2022 03:48AM
Why isn't it the default?

ほんとそう、なんか問題あるんでしょうか、未検証なのでしょうか?

ちなみに、Mermaid プラグインははっきり未対応のようです。

👉 Mermaid - IntelliJ IDEs Plugin | Marketplace hatena-bookmark


【OpenAI/ChatGPT】API リクエストしたら「You exceeded your current quota, please check your plan and billing details.」

無料で3ヶ月間、18ドル分使えるというので。


openai.api_key = os.getenv("OPENAI_API_KEY")
try:
  response = openai.Completion.create(
    engine="davinci",
    # engine="gpt-3.5-turbo",
    prompt="Hello, world!",
    max_tokens=5
  )
  print(response.choices[0].text)
except Exception as e:
  print(f"{e=}, {type(e)=}")

NGでした。


e=RateLimitError(message='You exceeded your current quota, please check your plan and billing details.', http_status=429, request_id=None), type(e)=<class 'openai.error.RateLimitError'>

利用量の確認をします。

Below you'll find a summary of API usage for your organization. All dates and times are UTC-based, and data may be delayed up to 5 minutes.
👉 Account - OpenAI API hatena-bookmark

利用の記録はないです。

無料18ドル分も付与されてない雰囲気。

「アカウント作成から3ヶ月以内。」ということですがそれは満たしている。

どういうことなんすかね!?

👉 How can I get Free Trial Credits? - General API discussion - OpenAI API Community Forum hatena-bookmark