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

このQ&Aのポイント
  • Java初心者が対策を教えてください
  • 上記のサイトをコピペしたがエラーが出ています
  • Androidアプリのプログラムでエラーが発生しています
回答を見る
  • ベストアンサー

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> このプログラムにエラが出ています

質問者が選んだベストアンサー

  • ベストアンサー
  • edomin7777
  • ベストアンサー率40% (711/1750)
回答No.1

どんな「エラ」?

hfiapoahoaphaip
質問者

補足

エラー: エラー: No resource found that matches the given name (at 'icon' with value '@drawable/icon'). というのが出ます。

関連するQ&A

  • 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>

  • 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> となってます。

  • 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
  • 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]エミュレータで動作しない原因

    こんにちは。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
  • 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)にて背面カメラを起動させるにはどうしたら宜しいのでしょうか。 ご指導御願い致します。

  • 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ビュー内のサイトから呼び出された場合、上記のマップを表示する場合どうしたらいいでしょうか??

  • ImageVeiwクラスからのカメラ起動

    AndroidアプリでImageVeiwクラスから既存のカメラアプリを起動することは可能か? よろしくお願いします。 imageViewクラスから、Activityクラスのメソッドにある Intent intent = new Intent(); intent.setAction("android.media.action.IMAGE_CAPTURE"); startActivity(intent); を呼び出そうとすると、カメラ起動時にエラーが発生します。 対処することは可能でしょうか?

  • ブラウザ出力エラーのリカバリ方法を教えてください

    javaでのAndroidアプリ作成時にWebKitを使って エミュレータでのアプリからのブラウザ出力を試していましたが、 実行時に『ページが見つかりませんでした』と表示されます。 このエラーの解決方法がありましたらご教示ください。 なお、以下に現状を記載しています。 <Activity> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView webview = new WebView(this); webview.loadUrl("http://www.google.co.jp"); setContentView(webview); } 【現状】 ・<uses-permission android:name="android.permission.INTERNET"></uses-permission>は設定済み ・実行デバイスを変更しても変化なし ・無線LANから有線LANに変更しても変化なし ・自身のネットワークはProxyサーバからのネットワークアクセスとなっており、  それに合わせたアクセスポイントの設定はAndroidエミュレータ内で設定済み ・エミュレータのブラウザからhttp://www.google.co.jpへはアクセス可 ・ソース内のエラーは無し ・assetsフォルダへのhtmlファイルの格納、webView.loadUrl(file:///~);での画面出力は可 以上です。宜しくお願いいたします。

  • 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; } } 長文で申し訳ありません。どうぞ宜しくお願い致します。

専門家に質問してみよう