我正在开发一个包含google map的android应用程序。当我更新Google Play服务并且compileSdkVersion大于25时,它运行良好,但是由于某些原因,我不想更新它。
我的应用程序级别gradle具有实现“ com.google.android.gms:play-services-maps:11.8.0”,而我的项目级别gradle具有类路径“ com.google.gms:google-services:3.1.1”
运行地图时,我遇到了这个异常。
ava.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/dynamic/DeferredLifecycleHelper;
at java.lang.Class.newInstance(Native Method)
at android.support.v4.app.Fragment.instantiate(Fragment.java:434)
at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3508)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
at com.tsengvn.typekit.TypekitLayoutInflater$WrapperFactory2.onCreateView(TypekitLayoutInflater.java:223)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at com.tsengvn.typekit.TypekitLayoutInflater.inflate(TypekitLayoutInflater.java:75)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.tsengvn.typekit.TypekitLayoutInflater.inflate(TypekitLayoutInflater.java:69)
at com.a1paradise.wifon.view.fragments.main.MapFragment.onCreateView(MapFragment.java:35)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2248)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1340)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamic.DeferredLifecycleHelper" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.a1paradise.wifon-OQzxZ4QXyddZsMW-3OtizA==/base.apk"],nativeLibraryDirectories=[/data/app/com.a1paradise.wifon-OQzxZ4QXyddZsMW-3OtizA==/lib/x86, /data/app/com.a1paradise.wifon-OQzxZ4QXyddZsMW-3OtizA==/base.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.newInstance(Native Method)
at android.support.v4.app.Fragment.instantiate(Fragment.java:434)
at android.support.v4.app.Fragment.instantiate(Fragment.java:409)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3508)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
at com.tsengvn.typekit.TypekitLayoutInflater$WrapperFactory2.onCreateView(TypekitLayoutInflater.java:223)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at com.tsengvn.typekit.TypekitLayoutInflater.inflate(TypekitLayoutInflater.java:75)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.tsengvn.typekit.TypekitLayoutInflater.inflate(TypekitLayoutInflater.java:69)
at com.a1paradise.wifon.view.fragments.main.MapFragment.onCreateView(MapFragment.java:35)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2248)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1340)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
我还在项目级别的gradle中使用了useLibrary'org.apache.http.legacy',但这没用。
我的编译和SDK版本:
compileSdkVersion 25
buildToolsVersion '27.0.3'
答案 0 :(得分:0)
您好,请添加此依赖项
实现'com.google.android.gms:play-services-maps:15.0.1'
实施'com.google.android.gms:play-services-plus:15.0.1'
实施'com.google.android.gms:play-services-location:15.0.1'
实现'com.google.maps.android:android-maps-utils:0.5'
并添加主项目gradle:
classpath'com.google.gms:google-services:4.0.1'