##onLocationChanged()が呼ばれないのですが、どうすればいいでしょうか?
@Override
public void onConnected(Bundle bundle) {}
は、しっかり呼ばれています。
原因がわからなかったため、シンプルな、https://akira-watson.com/android/fusedlocationproviderapi.html
このURLのサイトをコピペしてアプリを別に作成し、起動させましたが、onLocationChanged()が呼ばれることはありませんでした。どうぞよろしくお願いします。
コードは上記のサイトのコピペのものを使用しているため、字数的に、Manifest.xmlと、gradleファイルのみ記載しました。
すべてのcom.android.supportライブラリは、まったく同じバージョンの仕様を使用する必要があります(ミックスバージョンはランタイムクラッシュにつながる可能性があります)。バージョン25.0.1,24.0.0が見つかりました。例としては、com.android.support:support-v4:25.0.1およびcom.android.support:palette-v7:24.0.0 less ...(⌘F1)
互換性がない、またはバグにつながるライブラリやツールやライブラリの組み合わせがいくつかあります。このような非互換性の1つは、Androidサポートライブラリの最新バージョン(または特にtargetSdkVersionよりも低いバージョン)ではないバージョンでコンパイルされています。
こんなエラーが出てます。
##Manifest.xml
java
1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.android.sample.myapplication"> 4 5 <!-- ^^^ The above package name should modify to your project name. --> 6 7 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 8 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 9 10 <application 11 android:allowBackup="true" 12 android:icon="@mipmap/ic_launcher" 13 android:label="@string/app_name" 14 android:supportsRtl="true" 15 android:theme="@style/AppTheme"> 16 <meta-data 17 android:name="com.google.android.gms.version" 18 android:value="@integer/google_play_services_version" /> 19 20 <activity android:name=".MainActivity"> 21 <intent-filter> 22 <action android:name="android.intent.action.MAIN" /> 23 24 <category android:name="android.intent.category.LAUNCHER" /> 25 </intent-filter> 26 </activity> 27 <activity android:name=".LocationActivity"></activity> 28 </application> 29 30</manifest>
##Gradleアプリ
java
1 2apply plugin: 'com.android.application' 3android { 4 compileSdkVersion 25 5 buildToolsVersion "25.0.1" 6 7 defaultConfig { 8 applicationId "com.example.android.sample.myapplication" 9 minSdkVersion 24 10 targetSdkVersion 25 11 versionCode 1 12 versionName "1.0" 13 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 multiDexEnabled true 15 } 16 buildTypes { 17 release { 18 minifyEnabled false 19 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 } 21 } 22} 23 24dependencies { 25 compile fileTree(include: ['*.jar'], dir: 'libs') 26 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 exclude group: 'com.android.support', module: 'support-annotations' 28 }) 29 compile 'com.android.support:appcompat-v7:25.0.1' 30 testCompile 'junit:junit:4.12' 31 compile 'com.google.android.gms:play-services:9.6.1' 32 compile 'com.android.support:support-v4:25.0.1' 33 compile 'com.android.support:support-v13:25.0.1' 34}
##gradle
java
1// Top-level build file where you can add configuration options common to all sub-projects/modules. 2 3buildscript { 4 repositories { 5 jcenter() 6 } 7 dependencies { 8 classpath 'com.android.tools.build:gradle:2.3.3' 9 10 // NOTE: Do not place your application dependencies here; they belong 11 // in the individual module build.gradle files 12 } 13} 14 15allprojects { 16 repositories { 17 jcenter() 18 } 19} 20 21task clean(type: Delete) { 22 delete rootProject.buildDir 23} 24
回答1件
あなたの回答
tips
プレビュー