I've been trying to use the apache.poi library to create an excel file but, for some reason, I'm unable to import anything.
mainClassName = 'Main'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.22.0'
compile 'com.google.apis:google-api-services-sheets:v4-rev21-1.22.0'
compile 'org.apache.poi:poi:3.9'
}
When I am trying to write import org.apache.poi; it gives me an error saying "Package does not exist".
What is wrong with my dependencies? Thanks.
Some times it is useful to reload a gradle project so gradle could download the binary of the new dependency. After that the new packages should be available.
Found the same error while including gradle in the build.gradle file.
Use:
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
Like: dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
compile 'com.android.support:appcompat-v7:23.4.0'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "fl.gauravsngarg.com.inventory"
minSdkVersion 23
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'])
testCompile 'junit:junit:4.12'
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
compile 'com.android.support:appcompat-v7:23.4.0'
}
After research I found the actual version.
Use
// https://mvnrepository.com/artifact/org.apache.poi/poi
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
Its given here
https://mvnrepository.com/artifact/org.apache.poi/poi/3.9
The site contains all the official dependencies for gradle, maven, etc.
It worked for me:
It is quite possible that you have enabled gradle sync in offline mode.
Just change that.
Works like a charm
I had the same issue!
For me File > Invalidate Chaches / Restart > Invalidate and Restart worked.
I am using this version: https://mvnrepository.com/artifact/org.apache.poi/poi/4.1.2
Worked for me:
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.0'
Related
I added a few dependencies in my project and when I run it this error shows:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. > java.io.IOException: Can't write [D:\android\projects\android-client\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [D:\android\projects\android-client\app\build\intermediates\transforms\desugar\debug\47.jar(;;;;;;**.class)] (Duplicate zip entry [47.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))
and here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.arizeh.arizeh"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
versionCode 31
versionName "3.0.5"
useLibrary 'org.apache.http.legacy'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [manifestApplicationId : "",
onesignal_app_id : "",
onesignal_google_project_number: ""]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
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:26.0.0-beta1'
compile 'com.google.android.gms:play-services-plus:15.0.1'
compile 'com.google.android.gms:play-services-analytics:15.0.2'
compile 'com.google.android.gms:play-services-nearby:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile 'com.google.android.gms:play-services-base:15.0.1'
compile 'com.google.firebase:firebase-messaging:15.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.android.support:percent:26.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.shawnlin:number-picker:2.4.2'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-compat:26.1.0'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.2#aar'
compile 'com.zarinpal:purchase:0.0.3-beta'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile "com.android.support:support-core-ui:26.4.0"
implementation 'com.rahnema.vas3gapi:vas3g-api:2.0.0'
}
apply plugin: 'com.google.gms.google-services'
You need to use the same version of support library. In your dependencies block, you adding multiple version of support libraries:
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
compile 'com.android.support:design:26.1.0'
compile "com.android.support:support-core-ui:26.4.0"
use only one version either 26.1.0 or 26.4.0. Don't use beta version.
I think you have not added the dependency.
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
please add it and rebuild the project.I hope it will be work
Error:No such property: defaultConfig for class: java.lang.String
I am getting this error as soon as i sync my project but the same project is working fine in other people's computer.
i can not find the problem please help me fix this.
here is the build.gradle
apply plugin: 'com.android.application'
android {
android.defaultConfig.vectorDrawables.setUseSupportLibrary(true)
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
}
compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.Aven.andromedia"
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0"
testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
vectorDrawables {
useSupportLibrary = true
}
}
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:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'com.android.support:support-v4:26.3.1'
compile 'com.leo.simplearcloader:simplearcloader:1.0.+'
compile 'com.github.jd-alexander:LikeButton:0.2.3'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
compile 'com.jakewharton.timber:timber:3.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'com.github.vivchar:ViewPagerIndicator:v1.0.1'
compile 'com.github.GrenderG:Toasty:1.2.5'
compile 'com.anjlab.android.iab.v3:library:1.0.44'
compile 'com.yayandroid:ParallaxRecyclerView:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.29.0'
compile 'pl.bclogic:pulsator4droid:1.0.3'
compile 'com.jaredrummler:animated-svg-view:1.0.5'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
May I ask which gradle version you are running?
If the error occured after updating to gradle 3.0 you might wanna check out the Gradle 3.0 migration guide for help.
You should remove line android.defaultConfig.vectorDrawables.setUseSupportLibrary(true)
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all dependencies for configuration ':app:androidJacocoAgent'.
Could not resolve org.jacoco:org.jacoco.agent:0.7.5.201505241946.
Required by:
MYAPP:app:unspecified
No cached version of org.jacoco:org.jacoco.agent:0.7.5.201505241946 available for offline mode.
No cached version of
Blockquote
My project's build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 24
versionCode 8
versionName '2.0.6 BETA'
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit2:retrofit-adapters:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
}
It looks like some dependency needs org.jacoco:org.jacoco.agent:0.7.5.201505241946 as a dependency, but can't find it for some reason. It can be found in the maven repository side so it does exist. Add this line: compile group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.7.5.201505241946' to your dependencies list, so it will look like this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.7.5.201505241946'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit2:retrofit-adapters:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
}
This will add the dependency to your project and cut out the middle man so to speak.
For me it happened because android studio actually entered offline mode somehow. After disabling offline mode (Settings->Build, Execution, Deployment-> Gradle-> Offline work) dependency was successfully retrieved.
I had this problem because I need VPN to build (the jar repository is private), and VPN was not active.
This might be late to answer but I had the same problem and resolved by disabling offline mode. However, sometime offline mode don't show when you follow these steps
Settings (preferences on Mac)->Build, Execution, Deployment-> Gradle-> Offline work.
So what you can do instead is click on the Gradle (on right navigation) and choose the network icon (Toggle offline mode) and disable offline mode.
I hope it helps!
I want to use both javacv and gpuimagein my android application. Everything works fine if i only include javacv in my app. When i include gpuimage in my app, it crashes and shows this message.
java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:126)
at com.example.app.ShareActivity.initRecorder(ShareActivity.java:351)
at com.example.app.ShareActivity.access$1000(ShareActivity.java:49)
at com.example.app.ShareActivity$8.run(ShareActivity.java:398)
at java.lang.Thread.run(Thread.java:818)
This my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
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.android.support:support-v4:23.4.0'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
compile 'com.android.support:design:23.4.0'
compile 'org.bytedeco:javacv:1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.googlecode.mp4parser:isoparser:1.1.18'
}
i extracted ffmpeg-android-arm.jar and kept all *.so files inside app\src\jniLibs\armeabi. App works properly without gpuimage.
Remove
compile 'org.bytedeco:javacv:1.1'
from your Gradle and add the lines below
compile(group: 'org.bytedeco', name: 'javacv-platform', version: '1.3'){
exclude group: 'org.bytedeco.javacpp-presets'
}
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.2.1-1.3'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.2.1-1.3', classifier: 'android-arm'
I tried to work on Graphhopper demo project on Android Studio, which i found here: https://github.com/graphhopper/graphhopper/tree/master/android
After the Gradle building i got this error:
Error:Failed to resolve: com.graphhopper:graphhopper:0.6-SNAPSHOT
Now Android Studio cannot resolve symbols for Graphhopper classes.
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.graphhopper.android"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
/* CGIARProvider refers to java.awt
* Helper7 refers to java.lang.management
* HeightTile refers to javax.imageio and java.awt
* OSMElement refers to javax.xml.stream
*/
disable 'InvalidPackage'
}
}
/** only necessary if you need to use latest SNAPSHOT
configurations.all {
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
**/
dependencies {
compile(group: 'com.graphhopper', name: 'graphhopper', version: '0.6-SNAPSHOT') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}
compile group: 'org.mapsforge', name: 'mapsforge-core', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-android', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-reader', version: '0.5.2'
compile group: 'org.slf4j', name: 'slf4j-android', version: '1.7.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
It happens because com.graphhopper:graphhopper:0.6-SNAPSHOT is not in the central maven (or jcenter).
You can check all versions here.
The last stable version is 0.5.0
If you want to use the snapshot versions you have to add a repositoryin your build.gradle
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
Here the snapshot versions.