intellij idea 添加動態 user library(java.lang.VerifyError)【轉】


使用IDEA的時候有時要用到eclipse的user library,由於兩個IDE導入library的方式不同導致我們找不到導入user library的方法。
查IDEA的官方文檔,找到方法如下:
首先要導入user library :
 
 
Eclipse IDEA
Workspace Project
Project Module
Project-specific JRE Module JDK
User library Global library
Classpath variable Path variable
Project dependency Module dependency
Library Module library
那么我們在IDEA下要導入的就是Global library。
導入后加到module中,libray有個選項叫做Scope ,有如下值Compile  Test  Runtime Provided

                        Scope Use this drop-down to affect the classpath for the various build phases.
  • Compile: This is the default option. If it is selected, the dependency is resolved and is available in classpath during the compilation and run phases.
  • Test: Select this option, if this dependency is only required for tests, and should not be available in normal application use. If this scope is selected, the dependency is resolved and is available in classpath during the test compilation and run phases.
  • Runtime: This scope indicates that the dependency is only required when running the application, and should not be available in classpath during the compilation.
  • Provided: If this option is selected, the dependency is resolved and is available in classpath during the compilation, but is not included in classpath at runtime. This dependency scope is useful, when you have some container that provides the dependency at runtime.                  
由於我們要加入的是動態加載的庫,所以要求編譯的時候不加載,只有在運行用到的時候調用。
所以Scope選擇Provided選項。
默認是Compile,編譯的時候會隨module進行編譯,此處要改為Provided
 
搞定。
原文地址:http://blog.csdn.net/hlglinglong/article/details/29808575
 
現在有個需求是這樣。module A要用到user library,module A 使用上述方法將user library 導入,並將order 放置在Andorid SDK的上面。
module B要Dependency A
在mudule B中把A作為依賴庫導入,Scope選擇Provided ,出現如下錯誤
 java.lang.VerifyError
 
是因為庫的導入方式不對,
mudule B中把A作為依賴庫導入,Scope選擇Compile 。搞定


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM