LoginSignup
1
0

More than 5 years have passed since last update.

Android 「エラー: LinkedHashMapのEntryはpublicではありません。パッケージ外からはアクセスできません」

Posted at

何かのライブラリのバージョンを上げた際に以下エラーが出てしまいまして、

Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

こちらによると、
https://stackoverflow.com/questions/45862140/invokedynamic-requires-min-sdk-version-26
以下を追加すればよいみたいでした。


android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

しかし、これを追加した際に、以下部分で件名のエラーがでているようでした。

    LinkedHashMap<String, String> rokuyoMap = new LinkedHashMap<String, String>(){
        @Override
        protected boolean removeEldestEntry(Entry<String, String> eldest) {
            return size() > 5;
        }
    };

Map.Entry と明示的に?書くことでこのエラーは解消されました。
LinkedHashMapの中のEntryの記述を見ても、Map.Entryとなっていたので、こう書くのが普通なのでしょうかね。
今まで、なんでエラーになっていなかったか不思議

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0