java.lang.ClassNotFoundException in android 4.0 在 App 中添加 Ad Mob 后
java.lang.ClassNotFoundException in android 4.0 After Adding the Ad Mob in App
在 App 中添加 Ad Mob 后,它在 5.0 以上的更高版本中工作,但在 4.0 中不工作,我收到以下异常
java.lang.RuntimeException: Unable to instantiate service g2eandroid.srs.service.MyFirebaseInstanceIDService: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2570)
at android.app.ActivityThread.access00(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2567)
at android.app.ActivityThread.access00(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
请创建一个class
import android.content.Context;
import android.support.multidex.MultiDexApplication;
public class EnableMultiDex extends MultiDexApplication {
private static EnableMultiDex enableMultiDex;
public static Context context;
public EnableMultiDex(){
enableMultiDex=this;
}
public static EnableMultiDex getEnableMultiDexApp() {
return enableMultiDex;
}
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
}
并在您的清单中提供 android:name="packagename.EnableMultiDex"
例如:
<application
android:name="YourPakageName.EnableMultiDex"
android:hardwareAccelerated="true"
android:icon="@drawable/wowio_launch_logo"
android:label="@string/app_name"
android:largeHeap="true"
tools:node="replace">
让我知道它是否解决了您的问题。
在 App 中添加 Ad Mob 后,它在 5.0 以上的更高版本中工作,但在 4.0 中不工作,我收到以下异常
java.lang.RuntimeException: Unable to instantiate service g2eandroid.srs.service.MyFirebaseInstanceIDService: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2570)
at android.app.ActivityThread.access00(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2567)
at android.app.ActivityThread.access00(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
请创建一个class
import android.content.Context;
import android.support.multidex.MultiDexApplication;
public class EnableMultiDex extends MultiDexApplication {
private static EnableMultiDex enableMultiDex;
public static Context context;
public EnableMultiDex(){
enableMultiDex=this;
}
public static EnableMultiDex getEnableMultiDexApp() {
return enableMultiDex;
}
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
}
并在您的清单中提供 android:name="packagename.EnableMultiDex"
例如:
<application
android:name="YourPakageName.EnableMultiDex"
android:hardwareAccelerated="true"
android:icon="@drawable/wowio_launch_logo"
android:label="@string/app_name"
android:largeHeap="true"
tools:node="replace">
让我知道它是否解决了您的问题。