I'm getting a ClassNotFoundException for an app thats using Apache POI. I've tried running tests without Apache and it works fine, but when I add Apache's jars, it gives me this error:
java.lang.ClassNotFoundException: Didn't find class "com.example.mathcountsassign.MainActivity"
I've already tried cleaning the app, deleting the build file, reinstalling the jars, and re-importing the project. All the jar files are in libs.
My build.gradle:
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.mathcountsassign"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/commons-collections4-4.3.jar')
implementation files('libs/commons-compress-1.18.jar')
implementation files('libs/poi-4.1.0.jar')
implementation files('libs/poi-examples-4.1.0.jar')
implementation files('libs/poi-excelant-4.1.0.jar')
implementation files('libs/poi-ooxml-4.1.0.jar')
implementation files('libs/poi-ooxml-schemas-4.1.0.jar')
implementation files('libs/poi-scratchpad-4.1.0.jar')
implementation files('libs/xmlbeans-3.1.0.jar')
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mathcountsassign">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.example.mathcountsassign.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Longer Logcat message:
Process: com.example.mathcountsassign, PID: 25155
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.mathcountsassign/com.example.mathcountsassign.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.mathcountsassign.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.mathcountsassign-OBA_3amy6pZqKsYm6MIhpw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.mathcountsassign-OBA_3amy6pZqKsYm6MIhpw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2754)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2933)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at ...