cannot access NPOIFSFileSystem - java

I want to read xls and xlsx files.
I use this line to access my workbook.
myWorkBook = WorkbookFactory.create(file);
My build gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.application"
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
compile project(':aFileChooser')
}
I cannot compile my project as I get the following error:
Error:(210, 41) error: cannot access NPOIFSFileSystem
class file for org.apache.poi.poifs.filesystem.NPOIFSFileSystem not found
Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.
Any ideas what could be wrong?

Your problem is almost certainly these lines:
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
Specifically, two issues. Firstly, you must use matching versions of the Apache POI jars. It is not supported to use a mixture of old and new jars at the same time, they must all be from the same release. Secondly, both your jars are old ones, which due to their age miss some features.
Switch those to both be from POI 3.10.1 (or newer, eg 3.11 beta 2 as of writing), and you should then have the classes you need

Related

Program type already present error

Although many similar questions exist, I checked the answers to all and none of them worked for me!
Here is the error I'm facing while compiling the code:
Program type already present: android.support.v4.app.BackStackRecord$Op
Message{kind=ERROR, text=Program type already present: android.support.v4.app.BackStackRecord$Op, sources=[Unknown source file], tool name=Optional.of(D8)}
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.narsun.grocery"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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/LGPL2.1'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.sd6352051.niftydialogeffects:niftydialogeffects:1.0.0#aar'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup:android-times-square:1.6.5#aar'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.myinnos:AwesomeImagePicker:1.0.2'
implementation 'com.github.ratty3697:android-smart-animation-library:1.6'
implementation 'com.github.zcweng:switch-button:0.0.3#aar'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
implementation 'com.google.android.exoplayer:exoplayer:2.6.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
}
You can tell me if there is anything else to add to understand what I'm doing or where I'm wrong.
In case anyone comes here with a similar issue. In my case it was because I had included an appcompat JAR file in the libs folder as well as having implementation 'com.android.support:appcompat-v7:26.0.0' in my gradle file.
When I removed the JAR file, that fixed my issue.
Probably the packages versions are not compatible. Try downgrading com.android.support packages, namely appcompat
so - implementation 'com.android.support:appcompat-v7:27.0.1'
I want to share how you can understand the error message.
First method, check your dependencies in build.gradle:
In this case, if I tried to remove that implementation, the error gone.
Second method, Check libs folder of your app which included .jar files:
In this case, if I tried to move that .jar to somewhere else, the error gone.
For the info for other who will face the same error, I was able to solve my problem by removing the following library from my gradle file:
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
This was the library creating issues for me. Thanks
I'm including a custom aar in my app/libs folder, and I correctly added the flatLib object to the root build.gradle, but incorrectly added the '*.aar' to the fileTree implementation in the app/build.gradle:
build.gradle
allprojects {
repositories {
...
flatDir {
dirs 'libs'
}
}
}
app/build.gradle
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
^^^
BAD

Duplicate files copied in APK README.md in Android Studio Project [duplicate]

This question already has answers here:
Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt
(13 answers)
Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"
(20 answers)
Closed 6 years ago.
im trying to run this test in Android Studio using selendroid:
public class test_three {
SelendroidLauncher selendroidServer;
WebDriver driver;
public void startServer(){
SelendroidConfiguration config = new SelendroidConfiguration();
selendroidServer = new SelendroidLauncher(config);
selendroidServer.launchSelendroid();
}
#Before
public void beginTest() throws Exception {
DesiredCapabilities capa = DesiredCapabilities.android();
capa.setCapability(SelendroidCapabilities.EMULATOR, true);
driver = new SelendroidDriver(capa);
}
#Test
public void mainTest(){
driver.get("http://m.ebay.de");
WebElement element = driver.findElement(By.id("kw"));
element.sendKeys("Nexus 5");
element.submit();
}
#After
public void testEnd(){
if(driver != null){
driver.quit();
}
}
}
I have added the needed libraries (selendroid-client-0.17.0.jar and selendroid-standalone-0.17.0-with-dependencies.jar) before running and I have started the server thru the cmd. However, I get this error everytime I run it:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK README.md
File1: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-client-0.17.0.jar
File2: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-standalone-0.17.0-with-dependencies.jar
I have not really found any suggestions online on how to fix it. I hope you guys can help out. Thanks!
EDIT: Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
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/LGPL2.1'
}
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.training.sample_three"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/selendroid-client-0.17.0.jar')
compile files('libs/selendroid-standalone-0.17.0-with-dependencies.jar')
}
Just add this to your build.gradle file
packagingOptions {
exclude 'META-INF/README'}
packagingOptions {
exclude 'README'}
Try with above two options.
Please do some research before posting any question here. You can easily get answers for such questions on google.
Write below lines in your app level gradle file
android {
packagingOptions {
exclude 'META-INF/README'
}
}
Found here Android Gradle Duplicate files copied in APK META-INF/license.txt

Duplicate entry in build.gradle zznp.class

I am trying to implement Applozic chat in my existing android app. I am already using MQTT for server communication in other classes and its working fine. But after downloading the Applozic library through build.gradle I am getting an error while compiling the application. Applozic also seems to be using the same MQTT technology. The error says:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
The build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxxxx.xxxx.xxx"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
/*allprojects {
repositories {
jcenter()
maven {
url "https://repo.eclipse.org/content/repositories/paho-releases/"
}
maven { url "https://jitpack.io" }
}
}*/
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//testCompile 'junit:junit:4.12'
compile 'com.applozic.communication.uiwidget:mobicomkitui:4.62'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.volley:volley:1.0.+'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mukesh:permissions:1.0.2'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
/*compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
compile(project(':org.eclipse.paho.android.service')) {
transitive = true
}*/
}
task publishAPK(type: Copy) {
from file("${project.buildDir}/outputs/apk/" + rootProject.ext.sampleArchivesBaseName + "-debug.apk");
into '/shared/technology/paho/Android/' + rootProject.ext.sampleVersion + '/debug/';
}
configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3'
task debug << {
configurations.compile.each { println it}
}
I do not understand why the error shows up. Which library is causing the conflict? What do I need to modify in order to remove the issue?
The error is due to this compile 'com.google.android.gms:play-services:7.8.0'
lib as it is shown in the
error duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
try to remove this and sync the project .hope it work
Applozic android sdk is using Google play services v9.0.2 can you check by changing to v9.0.2
compile 'com.google.android.gms:play-services:9.0.2'
and if it exceeds 65k check this link
How to enable multidexing with the new Android Multidex support library

Android APP cant build because of httpcore

I am getting this error when I build my android app on my Machine, it runs perfectly on my old latptop/android enviroment , I get this error. Please let me know, if you need me to show more codes.
Old laptop is running one Android 1.2.2
Gradle 2.2.1 ??
my machine runs on 2.1.1
Gradle 2.10.0
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\AMHAPP\app\build\intermediates\libs3\httpcore-4.3.jar
(The system cannot find the path specified)
OR
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\TestApp.gradle\2.2.1\taskArtifacts\lib\jcifs-1.3.18.jar (The system cannot find the path specified)
Note: the following for the build paths of android studio
Example:
old machine :
compile files('C:/Users/Administrator/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
new machine:
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "AMH.Code.testapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android.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/LGPL2.1'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/jcifs-1.3.18.jar')
compile files('build/libs2/commons-io-2.4.jar')
compile files('build/intermediates/libs3/httpcore-4.3.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/apache-mime4j.jar')
compile files('libs/commons-io-2.4.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/apache-commons-net.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
compile files('libs/core-2.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/zbar.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
}
apply plugin: 'announce'
Try add this to your build.gradle
android {
useLibrary 'org.apache.http.legacy'
}
Either download jar for httpcore from here : http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.3.2
and add to your lib package and right click and add it as library
or
add gradle dependency in your gradle dependencies{} tag by adding :
compile 'org.apache.httpcomponents:httpcore:4.4.4'
and sync project.

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.jsonschema2pojo.gradle.)

This problem occurred after i updating my android studio to 2.0 when i try to run i get this:
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.jsonschema2pojo.gradle.GenerateJsonSchemaTask$_configureAndroid_closure4) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is not an inner class.
this is my build.gradle (Modeule: app)
Can someone explain to me how to solve this.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "tazligen.com.tazligen"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txtd'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
}
}
ext {
supportLibVersion = "23.2.1"
googlePlayServicesVersion = "8.4.0"
junitVersion = "4.12"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile "junit:junit:${junitVersion}"
// Android Support Library
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
// Networking libraries
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.6.2'
compile 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:0.4.16'
compile 'javax.annotation:jsr250-api:1.0'
compile 'org.apache.httpcomponents:httpmime:4.3.1'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'io.realm:realm-android:0.84.1'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.github.blackfizz:eazegraph:1.2.2#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
Well i solved the problem myself . Well i just removed the line
compile 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:0.4.16'
and it worked. Guess in android studio 2.0 this isn't required anymore. Anyways it worked for me.

Categories