2016-12-14 71 views
0

我想使用opencsv庫jar文件,但在導入時我收到錯誤消息說「無法從文件* .jar加載插件描述符」。在Android工作室2.2.1 java.bean。*找不到

我檢查了jar裏面的META-INF/plugin.xml文件,但沒有。

所以,我現在導入opencsv的源代碼。我在庫源代碼中使用的java 7 api出現錯誤。 'java.bean。*'包的所有用法都給出'找不到符號'的錯誤。

以下是build.gradle文件內容:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.amadeus.jbisht.mytestproject" 
     minSdkVersion 23 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.+' 
    testCompile 'junit:junit:4.12' 
} 

請讓我知道我錯過了。我可以看到它列在'外部圖書館'下,但android studio沒有選擇它。

回答

0

搖籃依賴是要走的路:

compile group: 'com.opencsv', name: 'opencsv', version: '3.8+' 

例如,

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.0' 
    compile group: 'com.opencsv', name: 'opencsv', version: '3.8+' 
} 

搖籃會自動導入所需的文件和集成庫。

0

opencsv需要一些java.bean庫,但它們不包含在Android SDK中。

要解決此問題:在你的Android Studio項目opencsv的

  • 下載源
  • 下載openbean
  • 包括
  • 通過localpath.bean.*在opencsv源替代java.bean.*依賴關係