简体   繁体   English

包含第三方库的Android项目中发生错误

[英]Error occurs in third party library included Android project

I got NoClassDefFoundError in every third party library project included in my android application. 我在Android应用程序中包含的每个第三方库项目中都收到了NoClassDefFoundError

When i configure Google Map V2 with my application, I got below error ; 当我使用应用程序配置Google Map V2时,出现以下错误;

09-07 01:35:09.429: E/AndroidRuntime(2061): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/model/LatLng;
09-07 01:35:09.429: E/AndroidRuntime(2061):     at com.taxsmart.collegeapp.support.GoogleMapActivity.<clinit>(GoogleMapActivity.java:34)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.reflect.Constructor.newInstance(Native Method)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.Class.newInstance(Class.java:1606)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.ActivityThread.access$800(ActivityThread.java:151)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.os.Handler.dispatchMessage(Handler.java:102)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.os.Looper.loop(Looper.java:135)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at android.app.ActivityThread.main(ActivityThread.java:5254)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.reflect.Method.invoke(Native Method)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.reflect.Method.invoke(Method.java:372)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
09-07 01:35:09.429: E/AndroidRuntime(2061): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.model.LatLng" on path: DexPathList[[zip file "/data/app/com.taxsmart.collegeapp-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-07 01:35:09.429: E/AndroidRuntime(2061):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-07 01:35:09.429: E/AndroidRuntime(2061):     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-07 01:35:09.429: E/AndroidRuntime(2061):     ... 15 more
09-07 01:35:09.429: E/AndroidRuntime(2061):     Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.maps.model.LatLng
09-07 01:35:09.429: E/AndroidRuntime(2061):         at java.lang.Class.classForName(Native Method)
09-07 01:35:09.429: E/AndroidRuntime(2061):         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
09-07 01:35:09.429: E/AndroidRuntime(2061):         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
09-07 01:35:09.429: E/AndroidRuntime(2061):         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
09-07 01:35:09.429: E/AndroidRuntime(2061):         ... 16 more
09-07 01:35:09.429: E/AndroidRuntime(2061):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

and also in other applications too , I got same error for other class of included library project. 并且在其他应用程序中,对于包含的库项目的其他类,我也遇到了相同的错误。

I use below sofware configurations: 我使用以下软件配置:

**Windows 10  64-bit
Eclipse Luna Service Release 2 (4.4.2) - 64-bit
Java SE – jdk-7u79-windows-x64
        jre-7u79-windows-x64
Android:
    Android SDK Tools – 24.3.4
    Android SDK Platform Tools – 23
    Android SDK Build-Tools – 18.0.1
    Google Play Services – Rev. 26**

Please help me to solve this issue. 请帮我解决这个问题。 Which configuration changes i needs to do? 我需要做哪些配置更改?

您可能需要将“ Build-Tool版本”升级到一些最新版本。

Since GMS library is in in the same workspace as your project, I guess it is just not linked. 由于GMS库与您的项目位于同一工作区中,所以我想它只是没有链接。

Right-click on your in Eclipse Package Explorer, select Properties , then Android from the list on the left. 右键单击Eclipse Package Explorer中的,选择Properties ,然后从左侧列表中选择Android

Click "Add.." button on the bottom of right pane, and select google-play-services-lib (or something similar) to add the library to the list. 单击右窗格底部的“添加..”按钮,然后选择google-play-services-lib(或类似名称)以将该库添加到列表中。

Check your project.properties file (in root folder of your project). 检查您的project.properties文件(在项目的根文件夹中)。 It should have a line like this: 它应该有这样的一行:

android.library.reference.1=../google-play-services-lib

Now clean the project an try to build it again. 现在清理项目,然后尝试再次构建它。 Hopefully, it will help. 希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM