In Android studio 2.2.1 java.bean.* not found - java

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.

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.

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

Related

Cannot resolve module dependency after updating to Android Studio 3.2.1

After upgrading to AS 3.2.1, I get this gradle sync error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :androidlib_abc.
my app gradle.build:
apply plugin: 'com.android.application'
allprojects {
repositories {
// The order in which you list these repositories matter.
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "de.gpx.android.rtk"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile project(path: ':androidlib_abc')
}
my androidlib_abc gradle.build file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
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.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
The "Open File" link in the error message points to the app gradle.build file. When I remove the line
compile project(path: ':androidlib_abc')
Then I can sync the grade project, but I cannot compile and use any package from that library (cannot resolve classes etc.)
I wish I didn't do the update... ("Never change a running system" -_-)
Any ideas how to fix?
UPDATE:
I removed the module from the project and then reimported it. Then everything worked fine! BUT: The module directory is copied into my project directory (usual behaviour). However, I need the module directory to be one level higher, in the same directory as the project directory is. This way, I could share the module with different projects without having duplicates and synchronizing work which saves me a lot of time (in fact I cannot work with multiple projects otherwise).
I used to use this settings.gradle file:
include ':app', ':androidlib_abc'
project(':androidlib_abc').projectDir = new File(rootProject.projectDir, '../androidlib_abc ')
which worked perfectly before AS 3.2.1
Now, after I successfully imported the module again and moved the module directory one level up and changed the settings.gradle file to this again, I get the unable-to-resolve-dependency error again :'-(
UPDATE2:
Using another constructor without the argument rootProject.projectDir allowed me to do the gradle sync.
include ':app', ':androidlib_abc'
project(':androidlib_abc').projectDir = new File('../androidlib_abc')
The library is finally listed on the left side!
However, a new issue came up. No classes/methods/fields etc. defined in the modul can be resolved. Not even in classes within the module itself although they are even in the same directory (package)... Cleaning and Rebuilding didn't help. Strange thing is, that building succeeds and I can apparently even install the app on my device and have it run without any exceptions...!? So is this just an IDE bug maybe?
UPDATE3
I deleted the .gradle and .idea directory and restarted AS. Everything's fine now B-)
try building androidlib_abc once .are you able to see this library in the side menu ?.
It could be that this particular library is not imported properly

All libraries must have the exact version

I dont quite understand this my sdk version is the same as my 'appcompat' and 'recyclerview' but it still has an error to it,I have tried rebuild and clean the project but still geting the same result, I have the same project to this one but it doesn't have an error like this one, any idea whats going on here?
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.parasitologymemorization.parasitologymemorization"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '**/*.so'])
compile 'com.android.support.constraint:constraint-layout:1.0.2'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.github.satyan:sugar:1.5'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.beardedhen:androidbootstrap:2.3.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.wonderkiln:camerakit:0.12.0'
compile(name: 'tensorflow', ext: 'aar')
}
Android Studio makes a lot of files as caches and does not delete them. This can cause trouble when there is a need to make new files, so clearing 'cacheswill clear the oldcache` and make Android Studio faster.
So you need to Invalidate Caches/Restart in Android Studio.
Whichever versions it says are wrong in the error message, compile the newest version in your gradle file, even if you don't think you're using them. I've run into this multiple times and that always fixes it.
For example, you should manually compile the recyclerview dependency with version 27.0.0
Just copy the com.android.support:animated vector drawable:27.0.0" in the build.gradle file and then change 27.0.0 to 26.0.1 and that sync the gradle.

Can't import: android.support.v7.widget.RecyclerView in Android Studio

I'm following my teachers tutorial and therefore writing exactly the same code that he has in his example. So I just created a new class to learn RecyclerView but I can't import RecyclerView On mouse-over, it just says "Cannot resolve symbol RecyclerView". I use Android Studio 2.3.3. Am I missing something obvious?
import android.support.v7.widget.RecyclerView;
public class CustomAdapter extends RecyclerView.Adapter<ComposedAdapter.Holder> {
//stuff
}
Gradle:
apply plugin: 'com.android.application'android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "sofialarsson.customrecyclerview"
minSdkVersion 19
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
You need to add dependencies in build.gradle
Use this update gradle file
apply plugin: 'com.android.application'android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "sofialarsson.customrecyclerview"
minSdkVersion 19
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.android.support:recyclerview-v7:25.0.0"
testCompile 'junit:junit:4.12'
}
Add below dependency in build.gradle;
compile 'com.android.support:design:xx.x.x'
If you are using androidx artifacts, add the following to your app level build.gradle
dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
}
Might be useful, so Let me drop this for those who might want to migrate to androidx. In your build.gradle (Module app) add the dependency like this, instead of:
compile 'com.android.support:recyclerview-v7:23.3.0'
to
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Then import like this, instead of:
import android.support.v7.widget.RecyclerView;
use:
import androidx.recyclerview.widget.RecyclerView;
Sync and enjoy!
Just add these two dependencies and you are good to go.
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
Make sure always always use same versions everywhere like you use here 25.3.1.
Also update your buildToolsVersion="25.0.0" .
Thanks!!!
Just add compile 'com.android.support:recyclerview-v7:25.3.1' dependencies in build.gradle app file like below code
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
}
Add below dependency in build.gradle
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta02'
Link Reference for latest releases
to give you an up-to-date and comprehensive answer, you have two choices.
Pre Android 9.0 (pre API 28), you have to use the old Support Library:
dependencies {
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.android.support:recyclerview-v7:25.0.0"
}
For these dependencies, you have to use the version number of your Build Tools Version.
In Android 9.0 (API 28+) and above, you have to use the new Support Library (Noted here https://developer.android.com/topic/libraries/support-library/features#v7):
dependencies {
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
}
For these dependencies, you have to use the version numbers from the following pages:
https://developer.android.com/jetpack/androidx/releases/appcompat
https://developer.android.com/jetpack/androidx/releases/recyclerview
Add this class in the main_activity.xml file:
class="androidx.recyclerview.widget.RecyclerView"/>
Refer to https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView
for more info...

Android : com.google.maps:google-maps-services:0.1.7 gives build errors

I tried to use Google Map Service by using com.google.maps:google-maps-services:0.1.7 version.
After adding complie 'com.google.maps:google-maps-services:0.1.7'to build.gradle(Module: app), I tried to sync the project.
Then I got following errors in Messages Gradle Sync,
D:\Solutions\Security\app\build.gradle
Error:(26, 0) Gradle DSL method not found: 'complie()'
Possible causes:The project 'AIGSecurity' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.2 and sync project
The project 'Security' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
And This is my build.gradle(Module: app) file,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "solutions.com.security"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
complie 'com.google.maps:google-maps-services:0.1.7'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'joda-time:joda-time:2.9.4'
compile 'com.auth0.android:jwtdecode:1.1.0'
compile 'com.android.support.constraint:constraint-layout:+'
androidTestCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Is there any way to fix this issue ?
you misspelled compile
complie 'com.google.maps:google-maps-services:0.1.7'
to
compile 'com.google.maps:google-maps-services:0.1.20'

Edit / Delete classes in external third party library jar files in android?

I am using external third party libraries in my project, but the problem I am facing is, two different jar files contains a class with the same name.
Following are the libs I am using
jaxen-1.1-beta-2.jar
jaxen-core.jar
The above given jar files share a class with the same name called "DefaultNavigator.class" so because of this i am getting the following duplicate class error.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/jaxen/DefaultNavigator.class
I need to know whether i can edit/delete unused classes or repeated classes given in the external third party jar files or please guide me whether i can copy only the classes that i required from all the jars and put them up in a single jar file and use. if this is possible please tell me how to do this. I am a beginner to android. Below I am attaching my build.gradle file.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xxx.xxx.yyy"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/xsdlib-1.5.jar')
compile files('libs/relaxngDatatype-2.2.jar')
compile files('libs/javax.xml.stream.jar')
compile files('libs/pull-parser-2.jar')
compile files('libs/javax.xml.bind.jar')
compile files('libs/java-rt-jar-stubs-1.5.0.jar')
compile files('libs/jaxen-core.jar')
compile files('libs/jaxen-dom4j.jar')
compile files('libs/jaxen-1.1-beta-2.jar')
}

Categories