LoginSignup
1
1

More than 5 years have passed since last update.

maven-android-pluginを使ったプロジェクトでApache Commonsを使ったコードをテストした時に落ちる時の対処法

Last updated at Posted at 2013-09-18

Apache Commonsに限らず別のライブラリ使った時にも起こるかも?
https://code.google.com/p/maven-android-plugin/issues/detail?id=142#c2

今回起きた状況はこんな感じ

  1. maven-android-pluginを使ってプロジェクトを作成する
  2. メインのコード内でCommonsのメソッドを使用する
  3. Commonsを使用してるメソッドをテストプロジェクトで呼び出す
  4. 実行時に落ちる

落ちる時にこんな感じのExceptionが投げられていた
IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

上の方で紹介したissuesのURLでも書かれているけど、最初に見つけたのはstackoverflowだった。
http://stackoverflow.com/questions/9684281/illegalaccesserror-class-ref-in-pre-verified-class-resolved-to-unexpected-imple

テストプロジェクトのpom.xmlに<scope>provided</scope>を追加したらいけた

pom.xml
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <scope>provided</scope>
</dependency>
1
1
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
1