谷歌地图无法正常工作:Classnotfound Exception?

时间:2018-02-04 08:39:53

标签: android google-maps

我使用Google SDK,Android Studion创建了Google地图标记示例项目。当涉及到执行时,bin文件似乎无法帮助我正确安装到设备上并使其工作。详细地说,Logcat显示以下消息:

类未找到异常错误日志

02-04 11:59:17.781 26119-26119/? E/Zygote: v2
02-04 11:59:17.781 26119-26119/? E/Zygote: accessInfo : 0
02-04 11:59:17.808 26119-26126/? E/art: Failed sending reply to debugger: Broken pipe
02-04 11:59:23.741 26119-26119/com.kosarsoft.charter123 E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
02-04 11:59:28.404 26119-26119/com.kosarsoft.charter123 E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.kosarsoft.charter123, PID: 26119
  java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/zza;
      at java.lang.reflect.Constructor.newInstance0(Native Method)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
      at android.support.v4.app.Fragment.instantiate(Fragment.java:345)
      at android.support.v4.app.FragmentContainer.instantiate(FragmentContainer.java:33)
      at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3689)
      at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
      at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350)
      at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
      at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:784)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:496)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:446)
      at android.app.Activity.setContentView(Activity.java:2544)
      at com.kosarsoft.charter123.TourismMapsActivity.onCreate(TourismMapsActivity.java:22)
      at android.app.Activity.performCreate(Activity.java:6942)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
      at android.app.ActivityThread.-wrap14(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6682)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.zza" on path: DexPathList[[zip file "/data/app/com.kosarsoft.charter123-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kosarsoft.charter123-1/lib/arm, /data/app/com.kosarsoft.charter123-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
      at java.lang.reflect.Constructor.newInstance0(Native Method) 
      at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
      at android.support.v4.app.Fragment.instantiate(Fragment.java:345) 
      at android.support.v4.app.FragmentContainer.instantiate(FragmentContainer.java:33) 
      at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3689) 
      at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111) 
      at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350) 
      at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39) 
      at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:784) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:496) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:378) 
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:446) 
      at android.app.Activity.setContentView(Activity.java:2544) 
      at com.kosarsoft.charter123.TourismMapsActivity.onCreate(TourismMapsActivity.java:22) 
      at android.app.Activity.performCreate(Activity.java:6942) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 
      at android.app.ActivityThread.-wrap14(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:154) 
      at android.app.ActivityThread.main(ActivityThread.java:6682) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 
a

以下是我的代码:

package com.kosarsoft.charter123;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.kosarsoft.charter123.R;

public class TourismMapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private Double lat = 36.2301;
    private Double lng = 59.6444;
    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tourism_maps);

        Bundle b = this.getIntent().getExtras();
        if (b != null) {
            lat = b.getDouble( "lat" );
            lng = b.getDouble( "lng" );
        }

        SupportMapFragment tourismMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById( R.id.tourismMap );

        tourismMapFragment.getMapAsync( this );
    }


    /*
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     * */

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng(-34, 151);
        //mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    }
}

布局:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tourismMap"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.kosarsoft.charter123.TourismMapsActivity" />

什么是问题? 请帮帮我

0 个答案:

没有答案