“java.lang.NoClassDefFoundError:com.google.android.gms.R $ string error”添加“libs / mpandroidchartlibrary-2-1-6.jar”后

时间:2016-01-16 19:56:53

标签: android gradle bar-chart

e 我在添加编译文件后发现了这个错误('libs / mpandroidchartlibrary-2-1-6.jar')。在添加mpandroidchartlibrary-2-1-6.jar

之前,它可以正常工作

致命的例外:主要                                                                       处理:com.pnp.papps.schoob,PID:11781                                                                       java.lang.NoClassDefFoundError:com.google.android.gms.R $ string                                                                           在com.google.android.gms.measurement.zza。(未知来源)                                                                           在com.google.android.gms.measurement.zza.zzaR(未知来源)                                                                           在com.google.android.gms.measurement.internal.zzn.zziJ(未知来源)                                                                           在com.google.android.gms.measurement.internal.zzz.zza(未知来源)                                                                           在com.google.android.gms.measurement.internal.zzw。(未知来源)                                                                           在com.google.android.gms.measurement.internal.zzaa.zzDj(未知来源)                                                                           在com.google.android.gms.measurement.internal.zzw.zzaT(未知来源)                                                                           在com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(未知来源)                                                                           在android.content.ContentProvider.attachInfo(ContentProvider.java:1616)                                                                           在android.content.ContentProvider.attachInfo(ContentProvider.java:1587)                                                                           在android.app.ActivityThread.installProvider(ActivityThread.java:4868)                                                                           在android.app.ActivityThread.installContentProviders(ActivityThread.java:4463)                                                                           在android.app.ActivityThread.handleBindApplication(ActivityThread.java:4403)                                                                           在android.app.ActivityThread.access $ 1500(ActivityThread.java:138)                                                                           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1259)                                                                           在android.os.Handler.dispatchMessage(Handler.java:102)                                                                           在android.os.Looper.loop(Looper.java:136)                                                                           在android.app.ActivityThread.main(ActivityThread.java:5095)                                                                           at java.lang.reflect.Method.invokeNative(Native Method)                                                                           在java.lang.reflect.Method.invoke(Method.java:515)                                                                           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786)                                                                           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)                                                                           在dalvik.system.NativeStart.main(本地方法)

**

  

添加编译后我发现了这个错误   文件( '库/ mpandroidchartlibrary-2-1-6.jar')。它正常工作   添加mpandroidchartlibrary-2-1-6.jar。

**

4 个答案:

答案 0 :(得分:12)

** 最后这项工作对我来说..

- >使用Gradle为Multidex配置应用。 http://developer.android.com/tools/building/multidex.html#mdex-gradle **

1)修改清单以引用MultiDexApplication类

       android {
compileSdkVersion 21
buildToolsVersion "21.1.0"

    defaultConfig {

        minSdkVersion 14
        targetSdkVersion 21
multiDexEnabled true
    }
dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

'}'

** 2)在清单中,将Multidex支持库中的MultiDexApplication类添加到应用程序元素中。

在清单文件的应用程序标记中添加以下行。**

<application

        android:name="android.support.multidex.MultiDexApplication">

答案 1 :(得分:4)

在清单中 - &gt;应用程序添加到行

 android:name="android.support.multidex.MultiDexApplication"

注意:如果您已经有任何Application类,只需使用 MultiDexApplication

扩展该应用程序类

答案 2 :(得分:0)

在app build.gradle文件中

android {  
  defaultConfig { 
     multiDexEnabled true 
   }  
}

dependencies { 
   compile 'com.android.support:multidex:1.0.1'
} 

比在Application类中扩展MultiDexApplication类

 public class myApplication extends MultiDexApplication {  
    @Override
    public void onCreate() {
       super.onCreate(); 
    }
 }

比你的Manifest添加myApplication类

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.application">
<application
    ....
    android:name=".myApplication">
    ....
</application>

答案 3 :(得分:0)

如果在启用multidex之后问题仍然存在,那么一切都要确保您的compileSdkVersion与构建工具兼容......

我不确定,但我有一些应用程序,问题仍然存在:

compileSdkVersion 25
buildToolsVersion "26.0.2"

改变成这样的东西后它起作用了:

compileSdkVersion 25
buildToolsVersion "25.0.3"