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

a 夏天 提交于 2019-12-19 04:13:02

问题


eI found this error after adding compile files('libs/mpandroidchartlibrary-2-1-6.jar'). It work properly before adding mpandroidchartlibrary-2-1-6.jar

FATAL EXCEPTION: main Process: com.pnp.papps.schoob, PID: 11781 java.lang.NoClassDefFoundError: com.google.android.gms.R$string at com.google.android.gms.measurement.zza.(Unknown Source) at com.google.android.gms.measurement.zza.zzaR(Unknown Source) at com.google.android.gms.measurement.internal.zzn.zziJ(Unknown Source) at com.google.android.gms.measurement.internal.zzz.zza(Unknown Source) at com.google.android.gms.measurement.internal.zzw.(Unknown Source) at com.google.android.gms.measurement.internal.zzaa.zzDj(Unknown Source) at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source) at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source) at android.content.ContentProvider.attachInfo(ContentProvider.java:1616) at android.content.ContentProvider.attachInfo(ContentProvider.java:1587) at android.app.ActivityThread.installProvider(ActivityThread.java:4868) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4463) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4403) at android.app.ActivityThread.access$1500(ActivityThread.java:138) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1259) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5095) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) at dalvik.system.NativeStart.main(Native Method)

**

I found this error after adding compile files('libs/mpandroidchartlibrary-2-1-6.jar'). It work properly befor adding mpandroidchartlibrary-2-1-6.jar .

**


回答1:


** Finally this work for me..

->Configuring Your App for Multidex with Gradle. http://developer.android.com/tools/building/multidex.html#mdex-gradle**

1)Modify your manifest to reference the MultiDexApplication class

       android {
compileSdkVersion 21
buildToolsVersion "21.1.0"

    defaultConfig {

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

'}'

**2) In your manifest add the MultiDexApplication class from the multidex support library to the application element.

Add following line in the application tag of manifest file.**

<application

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



回答2:


In Manifest -> Application add below line

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

Note: If you have already any Application class just extend that application class with MultiDexApplication




回答3:


In app build.gradle file

android {  
  defaultConfig { 
     multiDexEnabled true 
   }  
}

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

than in your Application class extends MultiDexApplication class

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

than in your Manifest add myApplication class

<?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>




回答4:


If the problem persists even after enabling multidex and everything make sure you have compiledSdkVersion compatible with the build tools...

I am not sure but I had some app with this and the problem persisted:

compileSdkVersion 25
buildToolsVersion "26.0.2"

It worked after changing to something like this:

compileSdkVersion 25
buildToolsVersion "25.0.3"


来源:https://stackoverflow.com/questions/34831445/java-lang-noclassdeffounderror-com-google-android-gms-rstring-error-after-ad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!