In Android studio 2.2.1 java.bean.* not found

1k views Asked by At

I am trying to use opencsv library jar file but while importing i am getting the error message saying "Fail to load plugin descriptor from file *.jar".

I checked for META-INF/plugin.xml file inside the jar, but there is none.

So, i am now importing the source code of opencsv. I am getting error with java 7 api used within the library source code. All the usages of 'java.bean.*' package is giving 'cannot find symbol' error.

Following is the build.gradle file content:

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'
}

Please let me know what am I missing here. I can see it listed under 'External Libraries' but android studio isnt picking it up.

2

There are 2 answers

0
Zwander On

Gradle dependencies are the way to go:

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

E.g.,

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+'
}

Gradle will automatically import the required files and integrate the library.

0
Alexandre Gombert On

opencsv need some java.bean libraries, but they are not included in the Android SDK.

To resolve this :

  • download sources of opencsv
  • download openbean
  • include both in your Android Studio project
  • replace java.bean.* dependancies by localpath.bean.* in opencsv sources