• 締切済み

Google maps API v2使用アプリ

を作っています。 ただマップを表示させるだけで言いのですが、色んなサイトを参考にして作っても毎回問題が発生したため終了しますと出て、起動できません。 試しにgoogle-play-servicesのサンプルのmapsをインストールしたのですが、同じでした。 (もちろんAPIキーは取得して、書き換えてます) インストールはeclipseでデバッグなどしてできたapkをSDカード上に置き、それをスマホ側でタッチしてインストールしてます。 サンプルすら動かないとなると、自分のスマホに問題ありですかね? 二年くらい前のものですが、一応Android4.0.4なのですが… 何が問題なのか分かりません。もちろんeclipse上のコードにエラーはでてないです。 下に長いですが、メイン、マニフェスト、レイアウトを載せます。 他に必要な情報があれば教えてください。 メイン文は package com.example.gps2; import android.os.Bundle; import android.support.v4.app.FragmentActivity; public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps);//レイアウトを読み込む } } レイアウトは <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" /> マニフェストは <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.gps2" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="18" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyAil_zFbdUol0hpUmtqHvMO84jj7Pl-658"/> <permission android:name="com.example.gps2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <uses-permission android:name="com.example.gps2.permission.MAPS_RECEIVE"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> となってます。

  • Java
  • 回答数1
  • ありがとう数7

みんなの回答

回答No.1

これみてこうですねって答えられる人いないと思うけど・・・ エラーがあるなら端末に実行時のエラーログ出てるでしょ?それ開示したほうが早いんじゃない?

kuzugr
質問者

補足

エラーログですか。 見方を調べて確認して見ます。

関連するQ&A

  • Java初心者なので教えてください

    上記のサイトをコピペしたんですけどできません。 対策を教えてください。 ↓参考URL http://labs.agenda-style.jp/blog/2011/02/android---google--.html <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.googlemaps" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.INTERNET"/> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps"/> <activity android:name=".GoogleMapsActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> このプログラムにエラが出ています

  • WEBから呼び出された場合、違うプログラムを実行

    教えて頂いた public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_g_main); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity"); intent.setData(Uri.parse("https://maps.google.com/")); startActivity(intent); } でマップが起動できました。 再度お尋ねしますが、普通の起動の場合WEBVIEWを表示させて、そのWEBビュー内のサイトから呼び出された場合、上記のマップを表示する場合どうしたらいいでしょうか??

  • Androidアプリ・SDKでの実行時エラー

    初めてアンドロイドアプリの開発をしています(多言語のプログラミング経験はありますが、JAVAは初めてです)。Eclipseで開発を行っていますが、ボタンをクリックしたら画面遷移をする、という処理を追加したところ、Android SDKで実行した際に 「アプリ名(パッケージ名)が予期せず停止しました。やり直してください。」 と出て、トップの画面も表示されなくなってしまいました。なお、Eclipse上ではエラーなどが出ていません。原因が解らず困っています。何かわかる方がいらっしゃいましたらお教え下さい。 以下がソースになります。 ■トップのActivity--------------------- package jp.xxxxx.xxxxx; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //ボタンを定義 Button btn1 = (Button) findViewById(R.id.btn1); //クリックイベント btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent( getApplicationContext() , SubActivity.class); startActivity(intent); } }); } } ■トップ画面のXML--------------------- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"> <ImageView android:id="@+id/topLogo" android:src="@drawable/logo" /> <LinearLayout android:id="@+id/linearLayout1"> <TextView android:id="@+id/btn1" android:text="@string/btn1text"></TextView> </LinearLayout> </LinearLayout> ■トップのAndroidManifest.xml--------------------- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jp.xxxxx.xxxxx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:label="@string/app_name" android:name="MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:label="@string/screenName2" android:name="SubActivity"> </activity> </application> </manifest> なお、Activityの「//ボタンを定義」以下をコメントアウトした際には画面は出てきます。何か初歩的な間違いをしているかもしれませんが、どうかよろしくお願いします。

    • ベストアンサー
    • Java
  • Nexus7(2013)背面カメラ使用方法

    いつもお世話になっております。 早速ですが、Android Studioにて現在Nexus7の背面カメラを使用したアプリを開発したいと思っております。 AndroidManifestに    <uses-permission android:name="android.permission.CAMERA" /> Activityに Intent intent = new Intent(); intent.setAction("android.media.action.IMAGE_CAPTURE"); startActivity(intent); とプログラムしたところ GalaxyNote3 動作確認:OK Nexus7(2013) 動作確認:NG android.hardware.cameraを要求するアプリはNexus7では利用できません。という記事を見つけ  <uses-feature android:name="android.hardware.camera" android:required="false"/> 上記をManifestに追加してみましたがダメでした。 Nexus7(2013)にて背面カメラを起動させるにはどうしたら宜しいのでしょうか。 ご指導御願い致します。

  • androidアプリ開発について

    androidアプリ開発初心者です。 やりたいことは、 スタートボタンを押して、自分のお気に入りのページに飛び、(例えばオークションなど)サイトを表示させ、何分間ごとに更新できるループ処理?などができればいいなと考えています。 スタートボタンを押してサイトを表示するまでは何とか作れたのですが、それ以降をどのように作ったらいいのか分かりません。 初心者的な質問で申し訳ないのですが、どのように書いたらよいのか教えてください。 コードはこのようになっています。 <<main.xml>> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="192dp" android:layout_height="wrap_content" android:text="スタート" /> </LinearLayout> <<MainActivity.java>> import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { Button btn =null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn=(Button)findViewById(R.id.button1); btn.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v){ Uri uri =Uri.parse("http://"); Intent intent=new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } 長文で申し訳ありません。どうぞ宜しくお願い致します。

  • Androidの画面遷移ができません(その2)

    前回の質問の続きです. 今度はページXXXXXから3つのボタン(AAAAA,BBBBB,CCCCCと仮定)を画面上に表示させ,ボタンに記載された通りの各ページAAAAA,BBBBB,CCCCCに画面遷移しようと考えています. AAAAA,BBBBB,CCCCCにはそれぞれ異なった画像が表示されるようにプログラミングしてあるのですが,すべてのボタンを押してもページAAAAAに画面遷移してしまい困っています. おそらくAndroidManifest.xmlの定義が間違えているのではないかと思っているのですが,どこに原因があるのでしょうか?解答よろしくお願いします. 【AndroidManifest.xml】 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sample.XXXXX" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="9" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".XXXXX" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="AAAAA"></activity> <activity android:name="BBBBB"></activity> <activity android:name="CCCCC"></activity> </application> </manifest>

  • Android アプリ Google APIの使用

    Win 7 Pro 32bit Core i3 3120M メモリ 4G Google Maps Apiを使用したAndroidアプリの開発環境を構築しようとしております。 Googleサイトより最新のADTをダウンロードし、SDKマネージャーよりGoogle Apisをインストール 仕様としたのですが、SDKマネージャの起動時に、 Fetching http://dl-ssl.google.com/android/repository/addons_list-2.xml Fetched Add-ons List successfully Fetching URL: http://dl-ssl.google.com/android/repository/repository-9.xml Done loading packages. Fetching http://dl-ssl.google.com/android/repository/addons_list-2.xml Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Permission denied: connect Fetched Add-ons List successfully Fetching URL: http://dl-ssl.google.com/android/repository/repository-9.xml Failed to fetch URL http://dl-ssl.google.com/android/repository/repository-9.xml, reason: Socket Permission denied: connect Done loading packages. Fetching URL: https://dl-ssl.google.com/android/repository/repository-9.xml Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-9.xml, reason: Socket Permission denied: connect Done loading packages. Fetching URL: https://dl-ssl.google.com/android/repository/repository-9.xml Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-9.xml, reason: Socket Permission denied: connect Done loading packages. と、メッセージが出てきます。これが原因かどうかはわからないのですが、SDKマネージャーからGoogle Apis( Android4.4.2 API19)のダウンロードができません。 本エラーを解決する方法またはGoogle APIsを直接インストールする方法がございましたら 教えてください。 ちなみに、Webに載っていた Force https~にチェックを入れる方法は試しました。 想像するに、SDKマネージャが当該URLに接続する権限を持っていないために発生するSocketExceptionのような気がします。

  • [Android]エミュレータで動作しない原因

    こんにちは。java、Android開発初心者です。 「test001」というAndroidプロジェクト、「test001_01」というクラスを作成し、マニフェストを書き換えました。実行すると、再起動して繰り返しても The application has stopped unexpectedly. Please try again. と表示されます。 原因と対処方法を教えていただけませんか。 宜しくお願い致します。 ★test001 Manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test001" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.test001.text001_01" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ★test001_01.java package com.example.test001; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.view.Menu; import android.widget.Button; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; public class test001_01 extends Activity { private Button startButton, stopButton; private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sub); startButton = new Button(this); startButton.setText("Button5"); stopButton = new Button(this); stopButton.setText("Button6"); textView = new TextView(this); textView.setText("TextView1"); textView.setBackgroundColor(Color.YELLOW); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(linearLayoutParams); linearLayout.addView(startButton, linearLayoutParams); linearLayout.addView(stopButton, linearLayoutParams); linearLayout.addView(textView, linearLayoutParams); setContentView(linearLayout); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }

    • ベストアンサー
    • Java
  • Androidのアクションバー背景色を変更したい

    独学でAndroidアプリ開発を勉強しています。 AndroidStudioで開発を行っており、タブの背景色を変更したいと思い、 いろいろなサイトを参考にstyle.xmlを書き換えたりしているのですが、 一向に変更されず、行き詰まっています。 【res/values/style.xml】 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="@style/Theme.AppCompat"> <item name="android:actionBarStyle">@style/MyActionBar</item> <!-- Customize your theme here. --> </style> <style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar"> <item name="android:background">@color/background_color</item> </style> </resources> 【res/values/color.xml】 <?xml version="1.0" encoding="utf-8"?> <resources> <color name="background_color">#3ADBC6</color> </resources> 【AndroidManifest.xml】 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jp.hogehoge.tabtestapp" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 最終的には、アクションバー及びタブの背景色を変更したいのですが、 どこか間違っている部分があるでしょうか? どなたか、ご指導いただけるとありがたいです。 どうぞ宜しくお願い致します。

  • Android Studio Kotlin エラー

    全部のファイルのR.layout.hogehoge_activityのところのRで赤くなってエラーが出ます。 API28 revision 6 emulator-5554 Android 9 Android Studio 3.1.4 SDK tools 26.1.1 言語 Kotlin たくさんアクティビティファイルがありますので、エラー内容がわかるであろう、MainActivityとbuild.gradleと、Manifestファイル、を書きました。 インターネットで調べたのですが、有益な情報が見つかりませんでしたので、詳しい方、お願い済ます。 エラー内容を記します。 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > Failed to process resources, see aapt output above for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 0s 13 actionable tasks: 1 executed, 12 up-to-date 1つめのファイル MainActivity package com.example.yusuke.mysql02 import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.preference.PreferenceManager import android.view.View import android.widget.EditText import com.example.yusuke.mysql02.Grobal.grobalusername import com.example.yusuke.mysql02.R.id.username import android.widget.TextView import android.widget.Toast import com.android.volley.Request import com.android.volley.toolbox.StringRequest import kotlinx.android.synthetic.main.activity_main.* import com.android.volley.Response import com.android.volley.toolbox.JsonObjectRequest import com.android.volley.toolbox.Volley import org.json.JSONObject class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } val jsonobj = JSONObject() fun nextactivity(v:View){ jsonobj.put("username",username.text) jsonobj.put("password",password.text) val URL = "http://www.example.com/registeractivity.php" val que = Volley.newRequestQueue(this@MainActivity) val req = JsonObjectRequest(Request.Method.POST,URL,jsonobj, Response.Listener{ response -> Grobal.grobalexsist = response.toString() },Response.ErrorListener { Grobal.grobalexsist = "0" }) que.add(req) var nametext : String = username.getText().toString() var passtext : String = password.getText().toString() Grobal.grobalusername = nametext Grobal.grobalpassword = passtext val intent = Intent(this,RegisteredActivity::class.java) startActivity(intent) } fun loginactivity(v: View){ val intent = Intent(this,LoginActivity::class.java) startActivity(intent) } } 2つ目のファイル build.gradle apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.yusuke.mysql02" minSdkVersion 20 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0-rc02' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.volley:volley:1.1.1' } 3つ目のファイル Manifestファイル <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.and

専門家に質問してみよう