我需要一些帮助来解决我在Android中遇到的问题。我有一个AAR库,其中嵌入了JAR。 lib被称为TSSLib,嵌入其中的JAR称为Pebble。
我在其他应用程序中使用过此库,但在我的最新应用程序中,我收到了DexPathList错误。请参阅下面的logcat。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.owen.myfirstapplication, PID: 2541
java.lang.NoClassDefFoundError: Failed resolution of: Lza/co/techss/pebble/Pebble;
at za.co.techss.tsslib.pebble_classes.fpebbles.FPebble.getPebble(FPebble.java:20)
at za.co.techss.tsslib.pebble_classes.fpebbles.FPMenu.setMenuTestName(FPMenu.java:64)
at za.co.techss.tsslib.pebble_classes.fpebbles.FPMenu.setMenuCaption(FPMenu.java:131)
at com.example.owen.myfirstapplication.MainActivity.<clinit>(MainActivity.java:17)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "za.co.techss.pebble.Pebble" on path: DexPathList[[dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-support-annotations-23.0.0_7098173c187ce97e6c8e0e5ed251f5cec7ba814b-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-internal_impl-23.0.0_20b69c5a7d9459fb495e50940c3ff3c34c562b52-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-com.android.support-support-v4-23.0.0_07957f4ba1b3cfc5a3b6ff6cbaad9d5567e413fd-classes.dex", dex file "/data/data/com.example.owen.myfirstapplication/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.0.0_12b550572c817a2cdd144744ac50da1530814fcf-classes.dex"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at za.co.techss.tsslib.pebble_classes.fpebbles.FPebble.getPebble(FPebble.java:20)
at za.co.techss.tsslib.pebble_classes.fpebbles.FPMenu.setMenuTestName(FPMenu.java:64)
at za.co.techss.tsslib.pebble_classes.fpebbles.FPMenu.setMenuCaption(FPMenu.java:131)
at com.example.owen.myfirstapplication.MainActivity.<clinit>(MainActivity.java:17)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "za.co.techss.pebble.Pebble" on path: DexPathList[[zip file "/data/app/com.example.owen.myfirstapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at ja
我还包含了我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.owen.myfirstapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Android应用清单:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.owen.myfirstapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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.0.0'
compile project(':tsslib')
}
MainActivity.java
package com.example.owen.myfirstapplication;
import android.util.Log;
import za.co.techss.tsslib.components.ComponentRoot;
import za.co.techss.tsslib.pebble_classes.fpebbles.FPMenu;
public class MainActivity extends ComponentRoot
{
private static FPMenu menuPebble;
static
{
try
{
menuPebble = new FPMenu();
menuPebble.setMenuCaption("Main Menu");
menuPebble.setMenuOption("Jobcard", GroupWizardProcess.class, "menu_contact_group");
}
catch (Exception e)
{
Log.e("MainActivity", "-----> Error in static constructor!", e);
}
}
@Override
public void wStart() throws Exception
{
}
@Override
public int wComponentResourceLayout() {return R.layout.activity_main;}
}
我不确定导致问题的原因或解决方法。我已尝试过在StackOverflow上推荐的几个修复程序,但似乎没有解决问题。
Android Studio版本:2.2.2
我将不胜感激。
谢谢