等待进程上线

时间:2016-12-12 15:15:14

标签: android google-maps

我在android studio中创建了一个基于谷歌地图的示例项目,但是当我运行它时它崩溃了。我使用智能手机进行测试,因为我的CPU不支持VT-x。

这是活动:

package com.example.giuseppe.provamaps;
import android.content.Context;
import android.support.multidex.MultiDex;
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;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
@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));
}

这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.giuseppe.provamaps">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>        
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
</application>

这是logcat输出:

INFO - tools.idea.ddms.adb.AdbService - Initializing adb using: C:\Users\Rosa\AppData\Local\Android\Sdk\platform-tools\adb.exe, client support = true 
INFO - tools.idea.ddms.adb.AdbService - Successfully connected to adb 
INFO - ditor.DeployTargetPickerDialog - Successfully obtained debug bridge 
WARN -                    #InstantRun - Instant Run enabled, but not doing an instant run build since: LEGACY_MULTIDEX_REQUIRES_ART 
INFO - a.gradle.invoker.GradleInvoker - About to execute Gradle tasks: [:app:assembleDebug] 
INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Android/Android Studio/jre 
INFO - a.gradle.invoker.GradleInvoker - Build command line options: [--configure-on-demand, -Pandroid.injected.invoked.from.ide=true, -Pandroid.injected.build.api=19, -Pandroid.injected.build.density=hdpi, -Pandroid.injected.build.abi=armeabi-v7a,armeabi, -Pandroid.injected.coldswap.mode=MULTIDEX, --init-script, C:\Users\Rosa\AppData\Local\Temp\asLocalRepo376.gradle] 
INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: [--configure-on-demand, -Pandroid.injected.invoked.from.ide=true, -Pandroid.injected.build.api=19, -Pandroid.injected.build.density=hdpi, -Pandroid.injected.build.abi=armeabi-v7a,armeabi, -Pandroid.injected.coldswap.mode=MULTIDEX, --init-script, C:\Users\Rosa\AppData\Local\Temp\asLocalRepo376.gradle] 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 129 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213329\threadDump-20161211-213329.txt 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 125 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213329\threadDump-20161211-213335.txt 
INFO - pl.ProjectRootManagerComponent - project roots have changed 
INFO - .diagnostic.PerformanceWatcher - Pushing properties took 254ms; general responsiveness: ok; EDT responsiveness: ok 
INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 3027ms; general responsiveness: 0/9 sluggish, 9/9 very slow; EDT responsiveness: 1/3 sluggish, 1/3 very slow 
INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 7 files to update 
INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 15232ms; general responsiveness: 3/35 sluggish, 26/35 very slow; EDT responsiveness: ok 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 163 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213404\threadDump-20161211-213404.txt 
INFO - pl.ProjectRootManagerComponent - project roots have changed 
INFO - a.gradle.run.MakeBeforeRunTask - Gradle invocation complete, success = true 
INFO - .diagnostic.PerformanceWatcher - Pushing properties took 15ms; general responsiveness: ok; EDT responsiveness: ok 
INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 48ms; general responsiveness: ok; EDT responsiveness: ok 
INFO -                    #InstantRun - Using legacy/main APK deploy task 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 135 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213616\threadDump-20161211-213616.txt 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 119 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213616\threadDump-20161211-213622.txt 
INFO - .diagnostic.PerformanceWatcher - High memory usage (free 68 of 1463 MB) while dumping threads to C:\Users\Rosa\.AndroidStudio2.2\system\log\threadDumps-20161211-205128-AI-145.3537739\20161211-213616\threadDump-20161211-213627.txt 
INFO - idea.run.AndroidProcessHandler - Adding device lge-lg_d505-ce1698dd to monitor for launched app: com.example.giuseppe.provamaps 
INFO -            #com.android.ddmlib - Opening a debugger listener at port 8600 for client with pid 21186 
WARN -            #com.android.ddmlib - IO Error while obtaining allocation status 
WARN -            #com.android.ddmlib - Adb rejected connection to client '21199': closed 
WARN -            #com.android.ddmlib - Adb rejected connection to client '21214': closed 
INFO -            #com.android.ddmlib - Opening a debugger listener at port 8602 for client with pid 21298 
INFO -            #com.android.ddmlib - Opening a debugger listener at port 8602 for client with pid 21312 
INFO -            #com.android.ddmlib - Opening a debugger listener at port 8602 for client with pid 21325 

我尝试使用adb kill-server,adb start-server,使chache / restart无效,使用其他设备,但没有任何作用

同样在adb logcat中有一个循环(当应用程序停止时):

D/WifiStateMachine: handleMessage: X
D/BubblePopupHelper: isShowingBubblePopup : false
D/BubblePopupHelper: isShowingBubblePopup : false
D/WifiStateMachine: handleMessage: E msg.what=131155
D/WifiStateMachine: processMsg: ConnectedState
D/WifiStateMachine: processMsg: L2ConnectedState
D/WifiNative-wlan0: doString: SIGNAL_POLL
D/wpa_supplicant: RX ctrl_iface - hexdump(len=11): 53 49 47 4e 41 4c 5f 50 4f 4c 4c
D/wpa_supplicant: wlan0: Control interface command 'SIGNAL_POLL'
D/wpa_supplicant: nl80211: survey data missing!

对不起我的英语,我希望有人可以帮助我。感谢所有

的build.gradle:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 25
  buildToolsVersion "25.0.1"
  defaultConfig {
    applicationId "com.example.giuseppe.provamaps"
    minSdkVersion 19
    targetSdkVersion 25
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
 })
  compile 'com.android.support:appcompat-v7:25.0.1'
  compile 'com.google.android.gms:play-services:10.0.1'
  testCompile 'junit:junit:4.12'
}

另一件事,如果我尝试启动没有谷歌地图活动的HelloWorld示例,它确实有用。

1 个答案:

答案 0 :(得分:0)

更改此依赖关系(在build.gradle中):

compile 'com.google.android.gms:play-services:10.0.1'

对于这个:

compile 'com.google.android.gms:play-services-maps:10.0.1'

仅依赖于地图组件,而不是依赖于整个Play服务库。